public string GenerateFile(ModelFile file) { try { int maxVal = int.Parse(file.MaxValue); Int64 _amount = Int64.Parse(file.FileAmount); using (BCRandomStream rndstream = new BCRandomStream(maxVal + 1)) { string fName = "GenerateFile" + file.Id + ".txt"; string path = Server.MapPath("~/" + fName); using (FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.ReadWrite)) { using (StreamWriter writeStream = new StreamWriter(fileStream)) { for (var i = 0; i < _amount; i++) writeStream.WriteLine(rndstream.Read()); } return fName; } } } catch { return null; } }
public FileStream GenerateFile(string inputParam, string amount) { int maxVal = int.Parse(inputParam); int _amount = int.Parse(amount); using (BCRandomStream rndstream = new BCRandomStream(maxVal+1)) { string path = Server.MapPath("~/GenerateFile.txt"); using (FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.ReadWrite)) { using (StreamWriter writeStream = new StreamWriter(fileStream)) { for (var i = 0; i < _amount; i++) writeStream.WriteLine(rndstream.Read()); } return fileStream; } } }