开发者

How do I create a text file on server or memory?

How do I create a text file and write the contents of a string to it? I plan to reference to the text file later. It could be on the se开发者_Go百科rver (root folder) or anywhere where I can reference it. Below is the string contents

 foreach (string s in strValuesToSearch)
            {

                if (result.Contains(s))

                    result = result.Replace(s, stringToReplace);


You could use the WriteAllText method:

string result = "foo bar";
File.WriteAllText(@"c:\foo.txt", result);


As long as you have proper permission to write on the server you can take advantage of the methods of the System.IO.File class

System.IO.File.WriteAllText

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜