[Help]Create program files folder when run[Solved]

Posts 1–15 of 17 · Page 1 of 2
[Help]Create program files folder when run[Solved]
Well this is VERY nooby, but I just started VB.

When the user runs the program I want a folder to be created in their program files, and a .txt inside that folder. I know how to do this, but how would I actually name the folder like "Test Program" and the .txt to actually contain text. How would I write text to the .txt when the programs runs?
[php]Io.Directory.CreateDirectory("Path")
[/php]
[php]
Using sWrite as new io.streamwriter("Path", append as boolean)
swrite.write(text)
end using[/php]
Getting alot of errors doing that.
Quote Originally Posted by Physcadelic View Post
Getting alot of errors doing that.
Good, since ik your code + errors, I can sure help you.

Oh wait...
Quote Originally Posted by Blubb1337 View Post
Good, since ik your code + errors, I can sure help you.

Oh wait...
Sorry, just telling you
Code:
Public Class Form1
     
     Io.Directory.CreateDirectory("C:\Program Files\programname")
   Using sWrite as new io.streamwriter("C:\Program Files\programname\filename.txt", append as boolean)
    swrite.write(Text in filename.txt)
    End Using
Errors: End using must be preceeded by a matching using.
Io.Directory.CreateDirectory("C:\Program Files\programname") - Declaration expected at IODirectory.CreateDirectory("C:\Program Files\programname") -
Declaration Expected at sWrite as new io.streamwriter("C:\Program Files\programname\filename.txt", append as boolean)
Statement cannot appear out of method body: Using sWrite as new io.streamwriter("C:\Program
Quote Originally Posted by Physcadelic View Post
Sorry, just telling you
Code:
Public Class Form1
     
     Io.Directory.CreateDirectory("C:\Program Files\programname")
   Using sWrite as new io.streamwriter("C:\Program Files\programname\filename.txt", append as boolean)
    swrite.write(Text in filename.txt)
    End Using
Errors: End using must be preceeded by a matching using.
Io.Directory.CreateDirectory("C:\Program Files\programname") - Declaration expected at IODirectory.CreateDirectory("C:\Program Files\programname") -
Declaration Expected at sWrite as new io.streamwriter("C:\Program Files\programname\filename.txt", append as boolean)
Statement cannot appear out of method body: Using sWrite as new io.streamwriter("C:\Program
Lolz I please you to actually look at code before C+Ping it.

[php]
IO.Directory.CreateDirectory("C:\Program Files\programname")
Using sWriter As new IO.StreamWriter("C:\Program Files\programname\test.txt", False)
sWriter.Write(String.Join(ControlChars.CrLf, New String() {"Please read", "The fucking code", "before you copy it"}))
End Using
[/php]

And put the code in a method body for gawds sake.
Instead of
Code:
Using sWrite as new io.streamwriter("C:\Program Files\programname\filename.txt", append as boolean)
    swrite.write(Text in filename.txt)
    End Using
use
Code:
IO.File.WriteAllText("C:\Program Files\programname\filename.txt", "Contents of filename.txt")
Quote Originally Posted by Iamazn1 View Post
Instead of
Code:
Using sWrite as new io.streamwriter("C:\Program Files\programname\filename.txt", append as boolean)
    swrite.write(Text in filename.txt)
    End Using
use
Code:
IO.File.WriteAllText("C:\Program Files\programname\filename.txt", "Contents of filename.txt")
Thanks, that worked, and thankyou too Blubb, I guess I'm just too stupid to understand your code..
Physcadelic, don't get all mad at me for voting against copy and pasting, there's no need to throw around negative rep just because you can't handle criticism.
Quote Originally Posted by Jason View Post
Physcadelic, don't get all mad at me for voting against copy and pasting, there's no need to throw around negative rep just because you can't handle criticism.
Lol, agree. Btw, what was the de-rep message ? :P
Quote Originally Posted by Hassan View Post


Lol, agree. Btw, what was the de-rep message ? :P
Quote Originally Posted by Physcadelic
Yeah I'm new, don't have to be a jerk..
So yeah... Thanks for the rep though Hassan.
Quote Originally Posted by Jason View Post
Physcadelic, don't get all mad at me for voting against copy and pasting, there's no need to throw around negative rep just because you can't handle criticism.
ohshit sorry about this, was a total overreaction
Anyone that reads this de-rep me
Quote Originally Posted by Physcadelic View Post
ohshit sorry about this, was a total overreaction
Anyone that reads this de-rep me
There's no need to de-rep you as I repped him already, but be careful next time. If you won't face the criticism, you won't be able to learn new things.
Quote Originally Posted by Hassan View Post


There's no need to de-rep you as I repped him already, but be careful next time. If you won't face the criticism, you won't be able to learn new things.
are you on drugs son? I rage all over the place to anyone who says im wrong!!!
Quote Originally Posted by 'Bruno View Post
are you on drugs son? I rage all over the place to anyone who says im wrong!!!
Yeah but you're never wrong so you have a reason to be annoyed
Posts 1–15 of 17 · Page 1 of 2
This thread is closed for replies.

Tags for this Thread

None

Talk with us