הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Question
Tuesday, January 19, 2016 3:29 AM
Hi,
I have been scouring the web for this all day and I cannot seem to find an example of this in VB.Net.
I'm trying to set the Downloads folder as the Initial Directory for an OpenFileDialog. However, as explained here, the GetFolderPath function that I would normally use doesn't provide a enum for the Downloads folder:
OpenFileDialogBrowse.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder. _)
I have found this example in C#, but I cannot get it to work in VB.Net:
public static class KnownFolder
{
public static readonly Guid Downloads = new Guid("374DE290-123F-4565-9164-39C4925E467B");
}
[DllImport("shell32.dll", CharSet=CharSet.Unicode)]
static extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid rfid, uint dwFlags, IntPtr hToken, out string pszPath);
static void Main(string[] args)
{
string downloads;
SHGetKnownFolderPath(KnownFolder.Downloads, 0, IntPtr.Zero, out downloads);
Console.WriteLine(downloads);
}
I have read the following MSDN articles, although I'm afraid they don't help me for an instantiation in VB.Net:
Thoughts?
Thanks.
All replies (5)
Tuesday, January 19, 2016 3:48 AM ✅Answered
Hi Kevin,
I had tried below article and it was working for me.
Please check
http://www.codeproject.com/Articles/878605/Getting-all-Special-Folders-in-NET
A user friendly computer first requires a friendly user
Tuesday, January 19, 2016 3:56 AM
Hi,
Thanks for the reply.
I have read that article and one of the links in my post includes a reference to it also.
However, it's not written in VB.Net so I'm having troubles converting it :/
Any help would be appreciated.
Tuesday, January 19, 2016 4:06 AM
Use any of below converters
http://www.developerfusion.com/tools/convert/csharp-to-vb/
http://codeconverter.sharpdevelop.net/SnippetConverter.aspx
Hope it will help you
A user friendly computer first requires a friendly user
Tuesday, January 19, 2016 4:09 AM
Thank you very much. I wasn't aware of them.
I'll give them a try and report back.
Cheers.
Tuesday, January 19, 2016 6:28 AM
All good! Thanks for your help :)