folder - Writing to a subfolder in c# -
I have trouble writing a text file in a folder, which I tried to create. He said that I do not have access to 'C: \'
Can anyone tell me how to fix this and how? Thanks! Edit: New code after modifications ... My goal is \\. Txt Write a text file can someone tell me how? Thanks! The solution is that what the others have said. As already mentioned, this line: An assignment ( You must remember that it is legal for This is actually not a problem with permissions; It is not possible that you really want to write in the root directory or the root directory, which is why you are not allowed in the first place. string file_name = Environment.CurrentDirectory; File_name + = @ "\."; File_name = (string) kababox 1. Selected value; File_name + = @ "\."; File_name + = (wire) combobox2.SelectedValue; TextWriter name = new streamer (file_name); Edit
var location = path. Cobine (environment. Current directory, (string) combobox1. Selected item); Directory.CreateDirectory (location); Var path = path Cobain (location, combobox 2. selected ingots); TextWriter name = new streamer (path, true);
file_name = (string) combobox1. Selected value;
= ) is incorrectly done instead of an assembly (
+ = ). This means that if
comboxbo1 The selected value is
null , your way
. , which is the root directory of the drive.
SelectedValue for
null , because there can be an empty selection in a combo box, in that case To handle, perhaps disabling your saved functionality until the combo box has valid selection.
Comments
Post a Comment