private bool CopyFiles() { try { int c = 0; DirectoryInfo di = new DirectoryInfo(BatchFolder); FileInfo[] rgFiles = di.GetFiles("*.csv"); foreach (FileInfo fi in rgFiles) { webservices.Service1 StoreFile = new Flaskefyldning.webservices.Service1(); using (StreamReader reader = new StreamReader(BatchFolder + fi.Name, Encoding.UTF7)) { bool AlreadySaved = false; int LineCount = 0; string[] SavedLines = new string[99]; string line; while ((line = reader.ReadLine()) != null) { foreach (string SavedLine in SavedLines) { if (line == SavedLine) AlreadySaved = true; } if (!AlreadySaved) { SavedLines[LineCount] = line; LineCount++; StoreFile.StringWriter(line, fi.Name, NetworkStorage); } } } File.Delete(BatchFolder + fi.Name); c++; } MessageBox.Show(c.ToString() + " batch sendt."); return true; } catch { return false; } }
private bool SaveFile(string name,string to,string from) { webservices.Service1 ReadFile = new Flaskefyldning.webservices.Service1(); ArticleFile GetFile = ReadFile.StringReader(name, from); using (StreamWriter writer = new StreamWriter(to + name + "x", true)) { int i = 0; while (i < GetFile.AllLines.Count()) { writer.WriteLine(GetFile.AllLines[i]); i++; } } if (File.Exists(DataFolder + name + "x")) { if (File.Exists(DataFolder + name)) File.Delete(DataFolder + name); File.Copy(DataFolder + name + "x", DataFolder + name); File.Delete(DataFolder + name + "x"); } return true; }