![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Oct 2005
Posts: 52
Rep Power: 4
![]() |
Access Denied
I'm trying to write a simple program that will just open a streamwriter and write a few lines of text to a txt file. However i want the txt file to be under the path c:\program files\file.txt. No matter what i try though the program constantly keeps crashing saying that access is denied to that path. How do i get around this?
|
|
|
|
|
|
#2 | |
|
Professional Programmer
Join Date: Feb 2005
Location: PA, USA
Posts: 253
Rep Power: 4
![]() |
Quote:
have you tried to make sure the path is valid first? dim MyPath as string = "c:\program files\file.txt"
try
if System.IO.File.Exists(MyPath)
'put code in here
else
msgbox("the damn path doesn't exist!!!")
endif
catch e as exception
msgbox(e.message)
end tryI know it didn't say there was a file not found file but sometimes the error messages are not smart enough to know this, I had this exact same problem last week due to a stupid mispelling. If this does not lead you to an answer to your problem, post pack again and we'll try something else. if this isn't the problem then most likely you have some sort of file permissions set through windows or something. if it does turn out that the path is not valid, put a breakpoint in your code and see what exactly is in your path variable to see where you went wrong.
__________________
I have never let my schooling interfere with my education. -Mark Twain- Xbox live gamertag: melbolt |
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Apr 2006
Location: Sweden
Posts: 13
Rep Power: 0
![]() |
I'll admit, that I'm not experienced in VB.Net. However. In C# you have to type an '@' before the string to format the text right. You could also try something like this:
string myPath = "c:\\my map\\myfile.txt" |
|
|
|
|
|
#4 |
|
Newbie
Join Date: May 2006
Posts: 5
Rep Power: 0
![]() |
Double slashes won't do anything in VB.NET except put extra slashes in the directory structure you're looking up
What OS are you using? 2000? 2003? XP? |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|