Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.
Line 91: fbd.RootFolder = System.Environment.SpecialFolder.MyComputer;
Line 92: fbd.ShowNewFolderButton = true;
Line 93: if (fbd.ShowDialog() == DialogResult.Cancel) Line 94: return;
protected void Button1_Click(object sender, EventArgs e)
{
FolderBrowserDialog x = new FolderBrowserDialog();
x.ShowDialog();
}
what i want is if user click the button means it will open dialog with submit cancel button to select directory path not a file.and if user click submit button means the path will be stored in a string??
Are you trying to use the FolderBrowserDialog in a web application? FolderBrowserDialog is a windows forms control and can be only used for a Windows Form. It will throw errors if you try to use it in a web application. On the web side there is no specific
control to select directory, although you can use the normal <input type="file"> html tag to select a file on the client machine.
There is no asp control to select the particular folder. As a security measure (IE 7 onwards), this access to the client's system is forbidden. However, you can use custom client side control with some security priviledges.
Regards
Srikanth Kasturi
Please "Mark As Answer" if my post serves purpose.
Marked as answer by girikas on Aug 06, 2012 12:55 PM
As mentioned there is no ASP.NET control to select the directory - since HTML specification itself does not support it because of security issues. Please explain what you are trying to acheive by making the user select a directory on his local pc, so that
we can help you better.
girikas
Member
73 Points
346 Posts
how to fix this error??/
Aug 06, 2012 05:43 AM|LINK
Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.
Line 91: fbd.RootFolder = System.Environment.SpecialFolder.MyComputer; Line 92: fbd.ShowNewFolderButton = true; Line 93: if (fbd.ShowDialog() == DialogResult.Cancel) Line 94: return;protected void Button1_Click(object sender, EventArgs e)
{
FolderBrowserDialog x = new FolderBrowserDialog();
x.ShowDialog();
}
what i want is if user click the button means it will open dialog with submit cancel button to select directory path not a file.and if user click submit button means the path will be stored in a string??
how to do this??
pls guide me friends
sanddy19
Participant
1058 Points
144 Posts
Re: how to fix this error??/
Aug 06, 2012 05:58 AM|LINK
Are you trying to use the FolderBrowserDialog in a web application? FolderBrowserDialog is a windows forms control and can be only used for a Windows Form. It will throw errors if you try to use it in a web application. On the web side there is no specific control to select directory, although you can use the normal <input type="file"> html tag to select a file on the client machine.
Saurabh Nandu
Systenics Solutions
My Blog
prabu.raveen...
Contributor
5032 Points
956 Posts
Re: how to fix this error??/
Aug 06, 2012 06:13 AM|LINK
Girikas,
try the below to achive this without folderbrowsedialog,
http://www.codeproject.com/Articles/21895/Directory-Browsing-in-ASP-Net-2-0
Srikanth Kas...
Contributor
4299 Points
883 Posts
Re: how to fix this error??/
Aug 06, 2012 06:14 AM|LINK
There is no asp control to select the particular folder. As a security measure (IE 7 onwards), this access to the client's system is forbidden. However, you can use custom client side control with some security priviledges.
Srikanth Kasturi
Please "Mark As Answer" if my post serves purpose.
girikas
Member
73 Points
346 Posts
Re: how to fix this error??/
Aug 06, 2012 06:32 AM|LINK
hi sanddy19,
thanks for ur reply...is there possible to do this using asp.net controls????
pls provide that coding...
sanddy19
Participant
1058 Points
144 Posts
Re: how to fix this error??/
Aug 06, 2012 08:44 AM|LINK
As mentioned there is no ASP.NET control to select the directory - since HTML specification itself does not support it because of security issues. Please explain what you are trying to acheive by making the user select a directory on his local pc, so that we can help you better.
Saurabh Nandu
Systenics Solutions
My Blog