Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void CreateDemoFile(int fileType)
- {
- var _assembly = Assembly.GetExecutingAssembly();
- CCriticalSection fileLock = new CCriticalSection();
- try
- {
- switch (fileType)
- {
- case 1:
- myResource = "CommercialClients.json";
- break;
- case 2:
- myResource = "ResidentialClients.json";
- break;
- }
- using (Stream stream = _assembly.GetManifestResourceStream(myResource))
- using (StreamReader reader = new StreamReader(stream))
- {
- string fileString = reader.ReadToEnd();
- }
- fileLock.Enter();
- if (!File.Exists(FilePath))
- {
- using (FileStream fs = File.Create(FilePath))
- {
- fs.Write(fileString, Encoding.UTF8);
- GlobalDebugger.DebugPrint(this.ProcessorID, String.Format("File {0} has been created with Demo Data", FilePath));
- localFileHash = generateHash(readJson());
- }
- }
- }
- catch (Exception ex)
- {
- GlobalDebugger.DebugPrint(this.ProcessorID, "Exception Occurred in FileProcessor.CreateFile : " + ex.Message);
- ErrorLog.Exception("Exception Occurred in FileProcessor.CreateFile", ex);
- }
- finally
- {
- fileLock.Leave();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement