Access denied...
-
I'm attempting to write a file to a removable drive. When the app gets to the point where it creates the StreamWriter, it's stops and tells me access to the *whatever*:\ drive denied. I have administrator rights, and have also given the app admin rights by "running as admin". Is there something I should be doing besides the usual to get this working? Is what I'm doing correct?
private void button1\_Click(object sender, EventArgs e) { string usbDriveLetter = listBox1.SelectedItem.ToString(); string sPath = usbDriveLetter; sPath = usbDriveLetter.ToString(); StreamWriter sw = new StreamWriter(sPath); ...and so on
Thank you for your input.
-
I'm attempting to write a file to a removable drive. When the app gets to the point where it creates the StreamWriter, it's stops and tells me access to the *whatever*:\ drive denied. I have administrator rights, and have also given the app admin rights by "running as admin". Is there something I should be doing besides the usual to get this working? Is what I'm doing correct?
private void button1\_Click(object sender, EventArgs e) { string usbDriveLetter = listBox1.SelectedItem.ToString(); string sPath = usbDriveLetter; sPath = usbDriveLetter.ToString(); StreamWriter sw = new StreamWriter(sPath); ...and so on
Thank you for your input.
-
Nope. Not write protected. I'm wondering, in the code I'm opening StreamWriter, but not actually writing anything yet. Could this be the problem?
-
I'm attempting to write a file to a removable drive. When the app gets to the point where it creates the StreamWriter, it's stops and tells me access to the *whatever*:\ drive denied. I have administrator rights, and have also given the app admin rights by "running as admin". Is there something I should be doing besides the usual to get this working? Is what I'm doing correct?
private void button1\_Click(object sender, EventArgs e) { string usbDriveLetter = listBox1.SelectedItem.ToString(); string sPath = usbDriveLetter; sPath = usbDriveLetter.ToString(); StreamWriter sw = new StreamWriter(sPath); ...and so on
Thank you for your input.
-
Nope. Not write protected. I'm wondering, in the code I'm opening StreamWriter, but not actually writing anything yet. Could this be the problem?
-
HEllo, I don't think that a drive letter is a correct path argument for the StreamWriter Constructor. You should use a path to a file! All the best, Martin
Even if the file doesn't exist yet? If that's the problem, boy do I feel like an idiot.
-
Even if the file doesn't exist yet? If that's the problem, boy do I feel like an idiot.
simplicitylabs wrote:
Even if the file doesn't exist yet?
Yes
simplicitylabs wrote:
If that's the problem, boy do I feel like an idiot
You shouldn't. But MSDN is your friend at this kind of proplems: http://msdn2.microsoft.com/en-us/library/36b035cb.aspx[^] All the best, Martin