|
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Guide
{
public class IO
{
public const int TempFileNameLength = 4;
private static Random random = new Random();
public static string CreateTempFile(string path, string ext)
{
string filePath;
do
{
string fileName = CreateTempFileName(ext);
filePath = Path.Combine(path, fileName);
}
while (File.Exists(filePath));
return filePath;
}
public static string CreateTempFileName(string ext)
{
return RandomFileName(TempFileNameLength) + ext;
}
private static string RandomFileName(int nChars)
{
StringBuilder s = new StringBuilder();
for (int i = 0; i < nChars; i++)
{
int k = random.Next(10 + 'Z' - 'A' + 1);
if (0 <= k && k <= 9)
s.Append((char)(k + '0'));
else if (k <= 10 + 'Z' - 'A')
s.Append((char)('A' + k - 10));
else
throw new Exception("Shouldn't be here");
}
return s.ToString();
}
public void RunProcess(string path, string arguments)
{
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.