|
-
Jan 1st, 2012, 10:17 AM
#1
Thread Starter
Lively Member
-
Jan 1st, 2012, 10:21 AM
#2
Re: VB Can't access file...
The problem is that you are trying to open the file twice. Both these lines open the file:
Code:
file = System.IO.File.Create(Cfile)
My.Computer.FileSystem.WriteAllText(Cfile, texttosave, True)
Mistakes like this could be easily avoided simply by reading the documentation, which seems an obvious step to me. This is from the documentation for the WriteAllText method:
If the specified file does not exist, it is created.
Obviously there is no need to call File.Create beforehand if WriteAllText will create the file anyway.
-
Jan 1st, 2012, 10:26 AM
#3
Thread Starter
Lively Member
Re: VB Can't access file...
Thank you! BTW I know i'm an idiot at this, but thats WHY I neeed help.
-
Jan 1st, 2012, 10:31 AM
#4
Re: VB Can't access file...
 Originally Posted by TeachMeVB
Thank you! BTW I know i'm an idiot at this, but thats WHY I neeed help.
You're not an idiot (I assume ). You're just new at it, but that's WHY you need to read the documentation. When you don't know how to do something, the first thing you should do is read the instructions. Whenever you are using a new type or member, it is a good idea to read the documentation for that type or member. When it doesn't work the way you expect, it's essential.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|