Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27349

VS 2008 How to replace a word in this code?

$
0
0
Hello! I was wondering if someone could please offer some advice on how I could do this, as I am completely stuck.

Code:

Sub Main()
        My.Computer.FileSystem.CreateDirectory("C:\Users\USER\AppData\Roaming")
End Sub

I have the following code to create a new folder in a user's account. What I am trying to do is make the word "USER" be whatever the current user's account name is. I know that I can get the current username using -

Code:

Environment.UserName
But I can't figure out how to make this work with the above code. I tried doing this -

Code:

My.Computer.FileSystem.CreateDirectory("C:\Users\" & Environment.UserName, "\AppData\Roaming")
But it says - "Too many arguments to 'Public Sub CreateDirectory(directory As String)"

If anyone could help me, I would really appreciate it! Thanks!

Viewing all articles
Browse latest Browse all 27349

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>