CClash.FileUtils.WriteTextFile C# (CSharp) Method

WriteTextFile() public static method

public static WriteTextFile ( string path, string content ) : void
path string
content string
return void
        public static void WriteTextFile(string path, string content)
        {
            int attempts = FileIORetryCount;
            do
            {
                try
                {
                    File.WriteAllText(path, content);
                    return;
                }
                catch (IOException)
                {
                    attempts--;
                    if (attempts == 0) throw;
                    System.Threading.Thread.Sleep(FileIORetrySleep);
                }
            } while (true);
        }

Usage Example

Example #1
0
 public void AddTextFileContent(string key, string filename, string content)
 {
     EnsureKey(key);
     FileUtils.WriteTextFile(MakePath(key, filename), content);
     if (Added != null)
     {
         Added(this, new FileCacheStoreAddedEventArgs()
         {
             SizeKB = content.Length * sizeof(char)
         });
     }
 }