|
-
Jan 10th, 2010, 06:19 AM
#1
Thread Starter
Lively Member
[RESOLVED] Why I can't create Folder on Desktop by VB
I don't know what went wrong, but I am not able to create a folder using the following code
Code:
My.Computer.FileSystem.CreateDirectory(Environ("%UserProfile%") & "\Desktop\abc")
Last edited by riteshtechie; Jan 10th, 2010 at 06:43 AM.
< advertising link removed by moderator >
-
Jan 10th, 2010, 06:31 AM
#2
Addicted Member
Re: Why I can't create Folder on Desktop by VB
You should write full path to directory. Here is simple code:
Code:
Dim strUser As String
strUser = Environment.UserName
My.Computer.FileSystem.CreateDirectory("C:\Documents and Settings\" & strUser & "\Desktop\abc")
-
Jan 10th, 2010, 06:39 AM
#3
Re: Why I can't create Folder on Desktop by VB
How about
Code:
My.Computer.FileSystem.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\abc")
-
Jan 10th, 2010, 06:40 AM
#4
Re: Why I can't create Folder on Desktop by VB
 Originally Posted by Blagojce
You should write full path to directory. Here is simple code:
Code:
Dim strUser As String
strUser = Environment.UserName
My.Computer.FileSystem.CreateDirectory("C:\Documents and Settings\" & strUser & "\Desktop\abc")
No No No No No!
Use the proper facilites provided by .Net.
What if someone is not using an English language version of Windows where "Documents and Settings" is called something totaly different? Or if documents and settings isn't on the C: drive?
Last edited by keystone_paul; Jan 10th, 2010 at 06:44 AM.
-
Jan 10th, 2010, 06:42 AM
#5
Thread Starter
Lively Member
Re: Why I can't create Folder on Desktop by VB
Thanks KeyStone andBlagojce for helping me out
< advertising link removed by moderator >
-
Jan 11th, 2010, 04:02 AM
#6
Addicted Member
Re: Why I can't create Folder on Desktop by VB
Yes keystone_paul, you're right.
I would have it in mind.
riteshtechie don't forget mark topic as resolved.
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
|