Hello all, having a problem with an auto save function.

System.IO.File.WriteAllLines(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), Form1.myList.ToArray());

basically it keeps telling me i dont have permissions, i even tried running my software with admin rights.

I do have a couple of questions,
1: I have not specified a text title, and System.IO.File.WriteAllLines does not let me specify a text title. Why? and how do i?

2: How do i set permissions? i have succesfully used system io with a save dialog and never had a permissions problem.

Recommended Answers

All 2 Replies

you should specify a file name as follows:

string[] deneme ={ "ali", "veli", "deli","oldu" };
			System.IO.File.WriteAllLines(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\myfile.txt", deneme);

Works perfectly now, tyvm.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.