// function that handles the copy folder button on UI private void CopyAllBTNClick(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(FileNameTB.Text) && DestinationTB.Text != FileNameTB.Text) { DirectoryInfo dir = new DirectoryInfo(FileNameTB.Text); // forces user to enter a destination to use button if (string.IsNullOrWhiteSpace(DestinationTB.Text)) { MessageBox.Show("Please enter a destination or source"); } else if (dir.Exists) { CopyDirectory.DirectoryCopy(FileNameTB.Text, DestinationTB.Text, true); MessageBox.Show($"{FileNameTB.Text} copied to {DestinationTB.Text}"); } else { MessageBox.Show("Folder copy failed, check full folder path"); } } }
public void CopyToStore(string noitaPath) { if (!Directory.Exists(Location)) { Directory.CreateDirectory(Location); } WriteSaveInfo(); GameHandler.ClearSave(Location); if (Directory.Exists(Path.Combine(noitaPath, "world"))) { CopyDirectory.Copy(Path.Combine(noitaPath, "world"), Path.Combine(Location, "world")); } if (File.Exists(Path.Combine(noitaPath, "player.salakieli"))) { File.Copy(Path.Combine(noitaPath, "player.salakieli"), Path.Combine(Location, "player.salakieli")); } if (File.Exists(Path.Combine(noitaPath, "world_state.salakieli"))) { File.Copy(Path.Combine(noitaPath, "world_state.salakieli"), Path.Combine(Location, "world_state.salakieli")); } }
private async void BtnCopyFolder_OnClick(object sender, RoutedEventArgs e) { if (dgUSB.SelectedItems.Count != 1) { MessageBox.Show(Localization.GetString("FrmUSBPrep", 37), Localization.GetString("Global", 68)); return; } var usb = (USBDrive)dgUSB.SelectedItems[0]; if (usb.Status != Status.Success) { MessageBox.Show(Localization.GetString("FrmUSBPrep", 38), Localization.GetString("Global", 68)); return; } var folderBrowserDialog = new FolderBrowserDialog(); if (folderBrowserDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } Enable(false); await new TaskFactory().StartNew(() => { var copyDirectory = new CopyDirectory(folderBrowserDialog.SelectedPath, usb.Letter); copyDirectory.Status += CopyDirectoryOnStatus; copyDirectory.Run(); }).ContinueWith(delegate { lblStatus.UpdateText("Done"); Dispatcher.Invoke(() => { Enable(); }); }); }
private void RestoreScriptingExamplesIfNeeded() { if (ScriptingDirectory.Contains(_scriptingRawDir) && !Directory.Exists(ScriptingDirectory)) { if (Directory.Exists(GlobalConfig.FullPath(_scriptingRawDir))) { CopyDirectory.Copy(GlobalConfig.FullPath(_scriptingRawDir), ScriptingDirectory); } else { throw new FileNotFoundException( $"Scripting examples not found in {GlobalConfig.FullPath(_scriptingRawDir)}"); } } if (CustomFunctionsDirectory.Contains(_customFunctionsRawDir) && !Directory.Exists(CustomFunctionsDirectory)) { if (Directory.Exists(GlobalConfig.FullPath(_customFunctionsRawDir))) { CopyDirectory.Copy(GlobalConfig.FullPath(_customFunctionsRawDir), CustomFunctionsDirectory); } else { throw new FileNotFoundException( $"Custom functions examples not found in {GlobalConfig.FullPath(_customFunctionsRawDir)}"); } } }
public void CopyBin() { var proj = item.ContainingProject; var projname = proj.FullName; var dest = Path.GetDirectoryName(projname); var conf = Path.Combine(dest, "web.config"); var src = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); // Copy to MSBuild extensions msbuild = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"MSBuild\johnshope.com\XamlImageConverter"); Directory.CreateDirectory(msbuild); /*Files.Copy(Path.Combine(src, "XamlImageConverter.targets"), msbuild); * Files.Copy(Path.Combine(src, "XamlImageConverter.dll"), msbuild); * Files.Copy(Path.Combine(src, "XamlImageConverter.pdb"), msbuild); * Files.Copy(Path.Combine(src, "Awesomium"), msbuild, ); * Files.Copy(Path.Combine(src, "gxps"), msbuild); * Files.Copy(Path.Combine(src, "html2xaml"), msbuild); * Files.Copy(Path.Combine(src, "ImageMagick"), msbuild); * Files.Copy(Path.Combine(src, "psd2xaml"), msbuild);*/ CopyDirectory.Copy(src, msbuild); var IsWeb = File.Exists(conf); if (!IsWeb) { return; } // copy lazy dll's var bin = Path.Combine(dest, "Bin"); var Silversite = File.Exists(Path.Combine(bin, "Silversite.Core.dll")); string binlazy; //if (Silversite) binlazy = Path.Combine(dest, "Silversite\\Bin"); //else binlazy = Path.Combine(bin, "Lazy"); if (IsWeb && !Directory.Exists(binlazy)) { Directory.CreateDirectory(binlazy); CopyDirectory.Copy(src, binlazy); /*Files.Copy(Path.Combine(src, "XamlImageConverter.dll"), binlazy); * Files.Copy(Path.Combine(src, "XamlImageConverter.pdb"), binlazy); * Files.Copy(Path.Combine(src, "Awesomium"), binlazy); * Files.Copy(Path.Combine(src, "gxps"), binlazy); * Files.Copy(Path.Combine(src, "html2xaml"), binlazy); * Files.Copy(Path.Combine(src, "ImageMagick"), binlazy); * Files.Copy(Path.Combine(src, "psd2xaml"), binlazy);*/ //var cache = Path.Combine(dest, "Images\\Cache"); //if (!Directory.Exists(cache)) Directory.CreateDirectory(cache); } // copy XamlImageConverter.Web.dll when not using Silversite. if (!Silversite && IsWeb) { Files.Copy(Path.Combine(src, "XamlImageConverter.Web.*"), bin); } }
public void RestoreScriptingExamples() { if (!Directory.Exists(DefaultScriptingDirectory) || !Directory.EnumerateFiles(DefaultScriptingDirectory).Any()) { if (Directory.Exists(PathUtility.GetFullPath(ScriptingRawDir))) { CopyDirectory.Copy(PathUtility.GetFullPath(ScriptingRawDir), DefaultScriptingDirectory); } else { throw new FileNotFoundException( $"Scripting examples not found in {PathUtility.GetFullPath(ScriptingRawDir)}"); } } if (!Directory.Exists(DefaultCustomFunctionsDirectory) || !Directory.EnumerateFiles(DefaultCustomFunctionsDirectory).Any()) { if (Directory.Exists(PathUtility.GetFullPath(CustomFunctionsRawDir))) { CopyDirectory.Copy(PathUtility.GetFullPath(CustomFunctionsRawDir), DefaultCustomFunctionsDirectory); } else { throw new FileNotFoundException( $"Custom functions examples not found in {PathUtility.GetFullPath(CustomFunctionsRawDir)}"); } } }
public void CopyTo(string strFolder, bool overwrite) { string strNewFile = strFolder + @"\" + FormationName + @".Form"; string strNewPlayFolder = strFolder + @"\" + FormationName + "@"; if (File.Exists(strNewFile) && !overwrite) { return; } if (File.Exists(FormationPath)) { File.Copy(FormationPath, strNewFile, true); } if (File.Exists(FormationPath + @".FD")) { File.Copy(FormationPath + @".FD", strNewFile + @".FD", true); } if (File.Exists(FormationPath + @".BMP")) { File.Copy(FormationPath + @".BMP", strNewFile + @".BMP", true); } if (Directory.Exists(strNewPlayFolder)) { Directory.Delete(strNewPlayFolder, true); } Directory.CreateDirectory(strNewPlayFolder); CopyDirectory.CopyFolderFiles(PlayFolderPath, strNewPlayFolder, true, null); }
public void RestoreFromStore(string noitaPath) { GameHandler.ClearSave(noitaPath); if (Directory.Exists(Path.Combine(Location, "world"))) { CopyDirectory.Copy(Path.Combine(Location, "world"), Path.Combine(noitaPath, "world")); } if (File.Exists(Path.Combine(Location, "player.salakieli"))) { File.Copy(Path.Combine(Location, "player.salakieli"), Path.Combine(noitaPath, "player.salakieli")); } if (File.Exists(Path.Combine(Location, "player.xml"))) { File.Copy(Path.Combine(Location, "player.xml"), Path.Combine(noitaPath, "player.xml")); } if (File.Exists(Path.Combine(Location, "world_state.salakieli"))) { File.Copy(Path.Combine(Location, "world_state.salakieli"), Path.Combine(noitaPath, "world_state.salakieli")); } if (File.Exists(Path.Combine(Location, "world_state.xml"))) { File.Copy(Path.Combine(Location, "world_state.xml"), Path.Combine(noitaPath, "world_state.xml")); } }
private void CopyMenuItem_Click(object sender, EventArgs e) { var path = GetSelectedNodePath(); if (path != null) { CopyDirectory?.Invoke(sender, new DirectoryEventArgs(path)); } }
public void ExecuteCopyDirectoryTest() { var activity = new CopyDirectory(); activity.SourceFolder = @"C:\Temp\Sourcefolder"; activity.TargetFolder = @"C:\Temp\Targetfolder"; activity.OverrideExisitingFiles = true; WorkflowInvoker.Invoke(activity); Assert.IsTrue(Directory.Exists(@"C:\Temp\Targetfolder")); }
static void Main(string[] args) { string srcIn, dstIn; Console.WriteLine("Enter source path: "); srcIn = Console.ReadLine().ToLower(); Console.WriteLine("Enter destination path: "); dstIn = Console.ReadLine().ToLower(); CopyDirectory cDir = new CopyDirectory(srcIn, dstIn); cDir.Copy(); }
void AddBuildConfig(BuildRuleConfig config) { BuildRuleConfig data = config.Clone() as BuildRuleConfig; Config.Add(data); if (data.IsCopyDirectory) { CopyDirectory.Add(data.Name); } if (!AllDirectory.Contains(data.Name)) { AllDirectory.Add(data.Name); } }
public void DirectorySuccessfullyCopiedreturnssuccess() { var info = A.Fake <ServerConnectionInformation>(); var server = A.Fake <FTPTestWrapperAbstract>(); info.UserName = "******"; info.PassWord = "******"; info.ServerName = "ftp://localhost"; FtpWebResponse a = null; A.CallTo(() => server.getResp()).Returns(a); CopyDirectory copydirectory = new CopyDirectory(info); String resp = copydirectory.create(server); Assert.IsTrue(resp.Equals("success")); }
private static void AddUnityShaderPluginToVSC() { string message = null; string pluginSourcePath = null; string pluginInstallPath = null; //OSX if (Application.platform == RuntimePlatform.OSXEditor) { pluginSourcePath = Application.dataPath + "/../VSCUnity/" + UnityShaderPluginName; pluginInstallPath = VSCPluginsPathOSX + "/" + UnityShaderPluginName; } //Win else if (Application.platform == RuntimePlatform.WindowsEditor) { pluginSourcePath = Application.dataPath + "\\..\\VSCUnity\\" + UnityShaderPluginName; pluginInstallPath = VSCPluginsPathWin + "\\" + UnityShaderPluginName; } else { message = "Adding Unity shader plugin to Visual Studio Code is not currently supported on " + Application.platform; } bool supportedPlatform = message == null; if (supportedPlatform) { if (Directory.Exists(pluginSourcePath)) { if (Directory.Exists(pluginInstallPath)) { Directory.Delete(pluginInstallPath, true); } CopyDirectory.Copy(pluginSourcePath, pluginInstallPath); message = "Successfully added Unity shader plugin to Visual Studio Code"; } else { message = "Couldn't find the Unity shader plugin:\n\n" + pluginSourcePath; } } EditorUtility.DisplayDialog("Add Unity shader plugin", message, "Ok"); }
/// <summary> /// バックアップ起動 /// </summary> public void Start() { string serverFolderPath = @"\\" + _ipaddress + @"\" + _rootdirectory.TrimStart('\\'); try { //接続テスト bool result = true; int connectTime = 0; while (result) { int status = NetworkConnection.Connect(serverFolderPath, _localpath, _loginuser, _loginpassword); if (status == (int)ERROR_ID.ERROR_SUCCESS) { result = false; connectTime = 0; //copy if (_copyinit == 0) { CopyDirectory _Info = new CopyDirectory(_localpath, _copydir); _Info.MyCopyEnd += new CopyDirectory.CopyEnd(_Info_MyCopyEnd); _Info.StarCopy(); } if (InitWatcher()) { // Begin watching. fsw.EnableRaisingEvents = true; } } else { if (connectTime > 20) { NetworkConnection.Disconnect(_localpath); logger.Info("[" + _ipaddress + "]は接続できません"); result = false; } connectTime++; } } } catch (Exception ex) { logger.Error(ex.Message); } }
public void RecreateDLC() { BuildRule.Clear(); CopyDirectory.Clear(); IgnoreConst.Clear(); if (BuildRule.Count == 0) { //配置资源 BuildRule.Add(new BuildRuleConfig("Config", BuildRuleType.Directroy, true)); BuildRule.Add(new BuildRuleConfig("Lua", BuildRuleType.Directroy, true)); BuildRule.Add(new BuildRuleConfig("Language", BuildRuleType.Directroy, true)); BuildRule.Add(new BuildRuleConfig("Excel", BuildRuleType.Directroy, true)); BuildRule.Add(new BuildRuleConfig("Text", BuildRuleType.Directroy, true)); BuildRule.Add(new BuildRuleConfig("CSharp", BuildRuleType.Directroy, true)); //图片资源 BuildRule.Add(new BuildRuleConfig("Sprite", BuildRuleType.Directroy)); BuildRule.Add(new BuildRuleConfig("BG", BuildRuleType.Directroy)); BuildRule.Add(new BuildRuleConfig("Icon", BuildRuleType.Directroy)); BuildRule.Add(new BuildRuleConfig("Head", BuildRuleType.Directroy)); BuildRule.Add(new BuildRuleConfig("Flag", BuildRuleType.Directroy)); BuildRule.Add(new BuildRuleConfig("Texture", BuildRuleType.Directroy)); //其他资源 BuildRule.Add(new BuildRuleConfig("Audio", BuildRuleType.Directroy)); BuildRule.Add(new BuildRuleConfig("AudioMixer", BuildRuleType.Directroy)); BuildRule.Add(new BuildRuleConfig("Material", BuildRuleType.Directroy)); BuildRule.Add(new BuildRuleConfig("Music", BuildRuleType.Directroy)); BuildRule.Add(new BuildRuleConfig("PhysicsMaterial", BuildRuleType.Directroy)); BuildRule.Add(new BuildRuleConfig("Video", BuildRuleType.Directroy)); //Prefab资源 BuildRule.Add(new BuildRuleConfig("Animator", BuildRuleType.Directroy)); BuildRule.Add(new BuildRuleConfig("Prefab", BuildRuleType.Directroy)); BuildRule.Add(new BuildRuleConfig("Perform", BuildRuleType.Directroy)); BuildRule.Add(new BuildRuleConfig("System", BuildRuleType.Directroy)); BuildRule.Add(new BuildRuleConfig("UI", BuildRuleType.Directroy)); //场景资源 BuildRule.Add(new BuildRuleConfig("Scene", BuildRuleType.File)); } if (IgnoreConst.Count == 0) { //忽略的Const IgnoreConst.Add("CONFIG_DLCItem"); IgnoreConst.Add("CONFIG_DLCManifest"); } }
public void DirectoryAlreadyExistsReturnsappropriatemessage() { var info = A.Fake <ServerConnectionInformation>(); var server = A.Fake <FTPTestWrapperAbstract>(); info.UserName = "******"; info.PassWord = "******"; info.ServerName = "ftp://localhost"; WebException ex = new WebException( "The remote server returned success (file found)", WebExceptionStatus.ProtocolError); Console.WriteLine(ex.Message); A.CallTo(() => server.getResp()).Throws(ex); CopyDirectory copydirectory = new CopyDirectory(info); String resp = copydirectory.create(server); Console.WriteLine(resp); Assert.IsTrue(resp.Equals("The remote server returned success (file found)")); }
// function that handles the copy single file button on UI private void Destination1BTNClick(object sender, RoutedEventArgs e) { string FullPathToFile = System.IO.Path.Combine(SourceTB.Text, FileNameTB.Text); FileInfo fi = new FileInfo(FullPathToFile); // forces user to enter a destination to use button if (string.IsNullOrWhiteSpace(DestinationTB.Text)) { MessageBox.Show("Please enter a destination"); } else if (fi.Exists) { CopyDirectory.SingleFileCopy(FullPathToFile, DestinationTB.Text, FileNameTB.Text); MessageBox.Show($"{FileNameTB.Text} succefully copied to {DestinationTB.Text}"); } else { MessageBox.Show("File copy failed, check FileName or source path"); } }
private void copy_Click(object sender, EventArgs args) { if (source != null && destination != null) { cDir = new CopyDirectory(source, destination); //Run the copy function in the background BackgroundWorker bg = new BackgroundWorker(); bg.DoWork += new DoWorkEventHandler(bg_DoWork); bg.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bg_RunWorkerCompleted); bg.RunWorkerAsync(); frm3 = new Form3(); frm3.Show(); //Update Form3 in background while copy function is running to show currently copying file BackgroundWorker bg2 = new BackgroundWorker(); bg2.DoWork += new DoWorkEventHandler(bg2_DoWork); bg2.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bg2_RunWorkerCompleted); bg2.RunWorkerAsync(); } else { MessageBox.Show("Please select a valid source and Destination", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 变化处理 /// </summary> /// <param name="state"></param> private void OnWatchedFileChange(object state) { IMonitorServerFileService MonitorServerFileService = BLLFactory.ServiceAccess.CreateMonitorServerFileService(); IMonitorServerFolderService MonitorServerFolderService = BLLFactory.ServiceAccess.CreateMonitorServerFolderService(); // File Info SortedList htfilescopy = (SortedList)htfiles.Clone(); Mutex mutex = new Mutex(false, "FSW"); mutex.WaitOne(); mutex.ReleaseMutex(); foreach (DictionaryEntry file in htfilescopy) { try { FileSystemEventArgs fileevent = (FileSystemEventArgs)file.Value; //源路径 string filepath = System.IO.Path.GetFullPath(file.Key.ToString()); //备份路径 string backuppath = Path.Combine(_copydir, fileevent.Name); MonitorServerFile monitorServerFile = new MonitorServerFile(); MonitorServerFolder monitorServerFolder = new MonitorServerFolder(); // copy機能 if (fileevent.ChangeType.Equals(WatcherChangeTypes.Created)) { // Copy方法変更 2014/01/30 変更 //bool result = FileSystem.FileCopy(filepath, backuppath); CopyDirectory fileCopy = new CopyDirectory(filepath, backuppath); fileCopy.StarCopy(); //IO問題であれば、次のファイルを処理する if (fileCopy._Errorlist.Count > 0) { foreach (string errorMessage in fileCopy._Errorlist) { logger.Error(errorMessage); } continue; } //if (!result) //{ // continue; //} //判断是否是目录 if (Directory.Exists(filepath)) { monitorServerFile.monitorFileType = Path.GetExtension(backuppath); monitorServerFile.monitorFileSize = "0"; monitorServerFile.monitorFileStatus = 1; //--- monitorServerFolder.monitorServerID = _id; monitorServerFolder.monitorFileName = Path.GetFileName(fileevent.Name); monitorServerFolder.monitorFilePath = filepath.TrimEnd(("\\" + Path.GetFileName(fileevent.Name)).ToCharArray()); monitorServerFolder.monitorFileType = "99"; monitorServerFolder.initFlg = "0"; monitorServerFolder.monitorFlg = "0"; monitorServerFolder.creater = "admin"; monitorServerFolder.updater = "admin"; monitorServerFolder.createDate = CommonUtil.DateTimeNowToString(); monitorServerFolder.updateDate = CommonUtil.DateTimeNowToString(); } else { System.IO.FileInfo fileinfo = new System.IO.FileInfo(backuppath); monitorServerFile.monitorFileType = Path.GetExtension(backuppath); monitorServerFile.monitorFileSize = fileinfo.Length.ToString(); monitorServerFile.monitorFileStatus = 1; //--- monitorServerFolder.monitorServerID = _id; monitorServerFolder.monitorFileName = Path.GetFileName(fileevent.Name); monitorServerFolder.monitorFilePath = filepath.TrimEnd(("\\" + Path.GetFileName(fileevent.Name)).ToCharArray()); monitorServerFolder.monitorFileType = Path.GetExtension(backuppath); monitorServerFolder.initFlg = "0"; monitorServerFolder.monitorFlg = "1"; monitorServerFolder.creater = "admin"; monitorServerFolder.updater = "admin"; monitorServerFolder.createDate = CommonUtil.DateTimeNowToString(); monitorServerFolder.updateDate = CommonUtil.DateTimeNowToString(); } //新增文件默认为监视,添加check MonitorServerFolderService.InsertMonitorServerFolder(monitorServerFolder); } else if (fileevent.ChangeType.Equals(WatcherChangeTypes.Changed)) { System.IO.FileInfo fileinfo = new System.IO.FileInfo(backuppath); if (fileinfo.IsReadOnly) { continue; } fileinfo.IsReadOnly = true; // Copy方法変更 2014/01/30 変更 //bool result = FileSystem.FileCopy(filepath, backuppath); CopyDirectory fileCopy = new CopyDirectory(filepath, backuppath); fileCopy.StarCopy(); //IO問題であれば、次のファイルを処理する if (fileCopy._Errorlist.Count > 0) { foreach (string errorMessage in fileCopy._Errorlist) { logger.Error(errorMessage); } continue; } //if (!result) //{ // continue; //} //判断是否是目录 if (Directory.Exists(filepath)) { monitorServerFile.monitorFileType = Path.GetExtension(backuppath); monitorServerFile.monitorFileSize = "0"; monitorServerFile.monitorFileStatus = 2; } else { monitorServerFile.monitorFileType = Path.GetExtension(backuppath); monitorServerFile.monitorFileSize = fileinfo.Length.ToString(); monitorServerFile.monitorFileStatus = 2; } } else if (fileevent.ChangeType.Equals(WatcherChangeTypes.Deleted)) { //判断被删除的目录是否存在 if (Directory.Exists(backuppath)) { monitorServerFile.monitorFileType = Path.GetExtension(backuppath); monitorServerFile.monitorFileSize = "0"; bool result = FileSystem.FileDelete(backuppath); //如果出现IO冲突,去执行下一个 if (!result) { continue; } monitorServerFile.monitorFileStatus = 3; } //判断被删除的文件是否存在 else if (File.Exists(backuppath)) { System.IO.FileInfo fileinfo = new System.IO.FileInfo(backuppath); fileinfo.IsReadOnly = false; monitorServerFile.monitorFileType = Path.GetExtension(backuppath); monitorServerFile.monitorFileSize = fileinfo.Length.ToString(); bool result = FileSystem.FileDelete(backuppath); //如果出现IO冲突,去执行下一个 if (!result) { continue; } monitorServerFile.monitorFileStatus = 3; } else { // File Info Remove htfiles.Remove(file.Key); continue; } } else if (fileevent.ChangeType.Equals(WatcherChangeTypes.Renamed)) { RenamedEventArgs refileevent = (RenamedEventArgs)file.Value; string oldfilename = refileevent.OldName.ToString(); string olddir = Path.Combine(_copydir, oldfilename); if (Path.GetExtension(olddir) == string.Empty) { //old file dir info insert if (Directory.Exists(olddir)) { MonitorServerFile monitorServerFile1 = new MonitorServerFile(); monitorServerFile1.monitorServerID = _id; monitorServerFile1.monitorFileName = Path.GetFileName(oldfilename); monitorServerFile1.monitorFilePath = olddir; monitorServerFile1.monitorFileType = Path.GetExtension(olddir); monitorServerFile1.monitorFileSize = "0"; monitorServerFile1.monitorStartTime = CommonUtil.DateTimeNowToString(); monitorServerFile1.monitorFileStatus = 3; monitorServerFile1.transferFlg = 0; monitorServerFile1.deleteFlg = 0; monitorServerFile1.creater = "exe"; monitorServerFile1.createDate = CommonUtil.DateTimeNowToString(); monitorServerFile1.updater = "exe"; monitorServerFile1.updateDate = CommonUtil.DateTimeNowToString(); MonitorServerFileService.InsertMonitorServerFile(monitorServerFile1, filepath); bool result = FileSystem.FileDelete(olddir); //如果出现IO冲突,去执行下一个 if (!result) { continue; } } // Copy方法変更 2014/01/30 変更 //bool result1 = FileSystem.FileCopy(filepath, backuppath); CopyDirectory fileCopy = new CopyDirectory(filepath, backuppath); fileCopy.StarCopy(); //IO問題であれば、次のファイルを処理する if (fileCopy._Errorlist.Count > 0) { foreach (string errorMessage in fileCopy._Errorlist) { logger.Error(errorMessage); } continue; } //if (!result1) //{ // continue; //} //new file dir info insert monitorServerFile.monitorFileType = Path.GetExtension(backuppath); monitorServerFile.monitorFileSize = "0"; monitorServerFile.monitorFileStatus = 4; //--- monitorServerFolder.monitorServerID = _id; monitorServerFolder.monitorFileName = Path.GetFileName(fileevent.Name); monitorServerFolder.monitorFilePath = filepath.TrimEnd(("\\" + Path.GetFileName(fileevent.Name)).ToCharArray()); monitorServerFolder.monitorFileType = "99"; monitorServerFolder.initFlg = "0"; monitorServerFolder.monitorFlg = "0"; monitorServerFolder.creater = "admin"; monitorServerFolder.updater = "admin"; monitorServerFolder.createDate = CommonUtil.DateTimeNowToString(); monitorServerFolder.updateDate = CommonUtil.DateTimeNowToString(); } else { //old file info insert if (File.Exists(olddir)) { MonitorServerFile monitorServerFile1 = new MonitorServerFile(); monitorServerFile1.monitorServerID = _id; monitorServerFile1.monitorFileName = Path.GetFileName(oldfilename); monitorServerFile1.monitorFilePath = olddir; System.IO.FileInfo fileinfo1 = new System.IO.FileInfo(olddir); monitorServerFile1.monitorFileType = Path.GetExtension(olddir); monitorServerFile1.monitorFileSize = fileinfo1.Length.ToString(); monitorServerFile1.monitorStartTime = CommonUtil.DateTimeNowToString(); monitorServerFile1.monitorFileStatus = 3; monitorServerFile1.transferFlg = 0; monitorServerFile1.deleteFlg = 0; monitorServerFile1.creater = "exe"; monitorServerFile1.createDate = CommonUtil.DateTimeNowToString(); monitorServerFile1.updater = "exe"; monitorServerFile1.updateDate = CommonUtil.DateTimeNowToString(); MonitorServerFileService.InsertMonitorServerFile(monitorServerFile1, filepath); fileinfo1.IsReadOnly = false; bool result = FileSystem.FileDelete(olddir); //如果出现IO冲突,去执行下一个 if (!result) { continue; } } // Copy方法変更 2014/01/30 変更 //bool result1 = FileSystem.FileCopy(filepath, backuppath); CopyDirectory fileCopy = new CopyDirectory(filepath, backuppath); fileCopy.StarCopy(); //IO問題であれば、次のファイルを処理する if (fileCopy._Errorlist.Count > 0) { foreach (string errorMessage in fileCopy._Errorlist) { logger.Error(errorMessage); } continue; } //if (!result1) //{ // continue; //} //new file info insert System.IO.FileInfo fileinfo = new System.IO.FileInfo(backuppath); monitorServerFile.monitorFileType = Path.GetExtension(backuppath); monitorServerFile.monitorFileSize = fileinfo.Length.ToString(); monitorServerFile.monitorFileStatus = 4; //--- monitorServerFolder.monitorServerID = _id; monitorServerFolder.monitorFileName = Path.GetFileName(fileevent.Name); monitorServerFolder.monitorFilePath = filepath.TrimEnd(("\\" + Path.GetFileName(fileevent.Name)).ToCharArray()); monitorServerFolder.monitorFileType = Path.GetExtension(backuppath); monitorServerFolder.initFlg = "0"; monitorServerFolder.monitorFlg = "1"; monitorServerFolder.creater = "admin"; monitorServerFolder.updater = "admin"; monitorServerFolder.createDate = CommonUtil.DateTimeNowToString(); monitorServerFolder.updateDate = CommonUtil.DateTimeNowToString(); } //重命名后文件默认为监视,添加check MonitorServerFolderService.InsertMonitorServerFolder(monitorServerFolder); } //insert database monitorServerFile.monitorServerID = _id; monitorServerFile.monitorFileName = Path.GetFileName(fileevent.Name); monitorServerFile.monitorFilePath = backuppath; monitorServerFile.monitorStartTime = CommonUtil.DateTimeNowToString(); monitorServerFile.transferFlg = 0; monitorServerFile.deleteFlg = 0; monitorServerFile.creater = "exe"; monitorServerFile.createDate = CommonUtil.DateTimeNowToString(); monitorServerFile.updater = "exe"; monitorServerFile.updateDate = CommonUtil.DateTimeNowToString(); MonitorServerFileService.InsertMonitorServerFile(monitorServerFile, filepath); // File Info Remove htfiles.Remove(file.Key); } catch (Exception e) { logger.Error(e.Message); continue; } } }
} // end DisplayMenu() public static bool GetResponce(String username, String password, String server, String getAnswer, LogFiles MyLogFile) { //string getAnswer = ""; bool MyAnswer = false; getAnswer = Console.ReadLine(); ServerConnectionInformation conn = new ServerConnectionInformation(username, password, server); switch (getAnswer) { case "14": Console.Clear(); Console.Write(username); Console.WriteLine(" Logged out from server! \n"); Console.WriteLine(" ########################################### \n"); //Set response to 'true' to logout MyLogFile.WriteLog(username + " Logged Out From Server " + server); MyAnswer = true; break; case "13": Console.Clear(); conn.Save(); Console.WriteLine("Connection Info Saved."); System.Threading.Thread.Sleep(2000); Console.Clear(); MyLogFile.WriteLog(username + "Saved Connecton Info"); MyAnswer = false; break; case "12": Console.Clear(); FileDownloadMultiple fdm = new FileDownloadMultiple(conn); string r = fdm.Download(); if (r == "disconnect") { Console.WriteLine("Download Files Failed\n"); MyLogFile.WriteLog(username + " downloading files failed"); } else if (r == "success") { Console.WriteLine("Download Files Successful\n"); MyLogFile.WriteLog(username + " downloading files successful"); } MyAnswer = false; break; case "11": //Put Multiple files on remote server PutMultipleFiles PutFilesToRemote = new PutMultipleFiles(conn); Console.WriteLine(" \n ** Specify local directory path of files to be uploaded \n (Mention absolute path in this format, for ex: C:/xyz/test/ ** \n"); String sourcefile_m = PutFilesToRemote.getFileName(); Console.WriteLine(" \n ** Specify files to be uploaded from aforementioned path. (Mention each file name separated by a comma. for ex: abc.txt, xyz.png, 123.txt). Filetypes accepted: .txt, .jpg, .png ** \n"); String inputfilenames_m = PutFilesToRemote.getFileName(); Console.WriteLine(" \n ** Specify directory name on server where source directory is to be copied (for ex: test). \n"); String destinationfileonserver_m = PutFilesToRemote.getFileName(); String res_m = PutFilesToRemote.CopyFiles(sourcefile_m, destinationfileonserver_m, inputfilenames_m); if (res_m == "success") { Console.Write("\n **** Uploade files complete. Please check messages for further info **** \n \n"); MyLogFile.WriteLog(username + " Upload Files Complete"); } else { Console.Write("\n **** Could not upload files due to an error: \n" + res_m + "\n"); MyLogFile.WriteLog(username + " Could Not Upload Files due to an error: " + res_m); } MyAnswer = false; break; case "10": //Copy Directory (including all files and subdirectory) CopyDirectory CopyDirectoryToRemote = new CopyDirectory(conn); Console.WriteLine(" ** Specify Directory to be copied to remote server \n (Mention absolute path in this format, for ex: C:/xyz/test/. Filetypes accepted: .txt, .jpg, .png ** \n"); String sourcefile = CopyDirectoryToRemote.getFileName(); Console.WriteLine(" \n ** Specify directory name on server where source directory is to be copied (for ex: test). \n"); String destinationfileonserver = CopyDirectoryToRemote.getFileName(); String res = CopyDirectoryToRemote.CopyDirectoryAndSubDirectories(sourcefile, destinationfileonserver); if (res == "success") { Console.Write("\n **** Successfully copied directory **** \n \n"); MyLogFile.WriteLog(username + "successfully copied source directory: " + sourcefile); MyLogFile.WriteLog(username + "successfully copied to destination directory: " + destinationfileonserver); } else { Console.Write("**** Could not copy directory due to an error.\n" + res + "\n"); MyLogFile.WriteLog(username + " - Copy from " + sourcefile + " to " + destinationfileonserver + " failed"); } MyAnswer = false; break; case "9": //Rename local file RenameLocal localRename = new RenameLocal(); Console.WriteLine("Enter the directory path followed by the file you wish to rename: "); Console.WriteLine("(i.e. C:\\xyz\\Desktop\\file.txt"); String fileLocal = Console.ReadLine(); Console.WriteLine("Enter the directory path followed by the new name for the file: "); Console.WriteLine("(i.e. C:\\xyz\\Desktop\\Newfile.txt"); String newFileLocal = Console.ReadLine(); String response10 = localRename.RenameFileLocal(fileLocal, newFileLocal); if (response10 == "success") { Console.Write("File renamed\n\n"); MyLogFile.WriteLog(username + " renamed local file: " + fileLocal + " to : " + newFileLocal); } else { Console.Write("Could not rename file due to an error.\n" + response10 + "\n\n"); MyLogFile.WriteLog(username + " could not rename local file " + fileLocal); } MyAnswer = false; break; case "8": Console.Clear(); ListDirectoryLocal list = new ListDirectoryLocal(); //get user input Console.WriteLine("Enter an absolute path to directory:"); string Dir = Console.ReadLine(); bool result = list.ListDirectory(Dir); MyLogFile.WriteLog(username + "Listed a local directory: " + Dir); MyAnswer = false; break; case "7": //Rename remote file RenameFileRemote renameRemote = new RenameFileRemote(conn); Console.WriteLine("Enter the file you wish to rename: \n"); String fileRename; fileRename = Console.ReadLine(); Console.WriteLine("Enter the name which you wish to rename the file with: \n"); String newName; newName = Console.ReadLine(); String response2 = renameRemote.RenameFileOnRemoteServer(fileRename, newName); if (response2 == "success") { Console.Write("File renamed\n"); MyLogFile.WriteLog(username + "renamed remote file " + fileRename + " to " + newName); } else { Console.Write("Could not rename file due to an error.\n" + response2 + "\n"); MyLogFile.WriteLog(username + "could not rename remote file " + fileRename + " to " + newName); } MyAnswer = false; break; case "6": Console.WriteLine("You chose - 6: Change Permissions. Please Note that Changing Permissions Requires an *NIX Server supporting 'SITE CHMOD'. Windows Servers are not supported."); //Change file permissions ChangePermissions perms = new ChangePermissions(conn); FluentWrapper permwrapper = new FluentWrapper(); permwrapper.setConn(conn); perms.setDir(permwrapper); perms.setPerms(permwrapper); String permresponse = perms.change(permwrapper); if (permresponse.Equals("Server Validation Failed\n") == true) { Console.WriteLine("\nServer Validation Failed"); MyLogFile.WriteLog(username + "could not change permissions"); MyAnswer = true; } else { if (permresponse.Equals("success")) { Console.WriteLine("Permissions Changed"); MyLogFile.WriteLog(username + "Changed Permissions"); } else { Console.WriteLine("Could Not Change Permissions due to Error:"); Console.WriteLine(permresponse); MyLogFile.WriteLog(username + " Could not change permissions"); } MyAnswer = false; } break; case "5": Console.WriteLine(" You chose 5, Delete File From Remote: \n"); //Delete file on remote server DeleteFromRemote deleteRemote = new DeleteFromRemote(conn); Console.WriteLine("Enter the file you wish to delete: \n"); String file; file = Console.ReadLine(); String response1 = deleteRemote.DeleteFileOnRemoteServer(file); if (response1 == "success") { Console.Write("File deleted\n"); MyLogFile.WriteLog(username + " Successfully deleted file " + file); } else { Console.Write("Could not delete file due to an error.\n" + response1 + "\n"); MyLogFile.WriteLog(username + " Could not delete file due to an error. " + file + " " + response1); } MyAnswer = false; break; case "4": Console.WriteLine(" You chose 4, Create Directory: \n"); //create remote directory CreateRemoteDirectory createRemDir = new CreateRemoteDirectory(conn); FtpTestWrapper newdirwrapper = new FtpTestWrapper(); String directory = createRemDir.getDirectoryName(); createRemDir.setWrapper(newdirwrapper); createRemDir.setup(directory); String changeresponse = createRemDir.create(createRemDir.getWrapper()); if (changeresponse == "success") { Console.Write("Directory Created\n"); MyLogFile.WriteLog(username + " Successfully Created Directory " + directory); } else if (changeresponse == "disconnect") { //If lost connection to server, log out MyLogFile.WriteLog(username + "lost connection"); MyAnswer = true; break; } else { Console.Write("Could not create directory due to an error.\n" + changeresponse + "\n"); MyLogFile.WriteLog(username + "Could not create directory due to an error: " + directory + " " + changeresponse); } MyAnswer = false; break; case "3": Console.WriteLine(" You chose 3, List Files In Directory: \n"); ListFiles listFiles = new ListFiles(conn); String response3 = listFiles.ListFilesOnRemoteServer(); if (response3 == "success") { Console.Write("Success: These are the files in the directory: \n"); MyLogFile.WriteLog(username + "Listed files in remote directory"); } else { Console.Write("Error: Can not list files in current directory. \n" + response3 + "\n"); MyLogFile.WriteLog(username + "Could not list files in remote directory"); } MyAnswer = false; break; case "2": Console.Clear(); Console.WriteLine(" You chose: Upload file to Remote server \n"); //File upload FileUpload uploadfile = new FileUpload(conn); FtpTestWrapper wrapper_file = new FtpTestWrapper(); Console.WriteLine(" ** Specify file to be uploaded \n (Mention absolute path in this format, for ex: C:/xyz/rst/abc.filetype. Filetypes accepted: .txt, .jpg, .png ** \n"); String filetobeuploaded = uploadfile.getFileName(); Console.WriteLine(" \n ** Specify valid directory on server where file is to be uploaded (for ex: Enter TEST for ftp://localhost/TEST) \n"); String locationonserver = uploadfile.getFileName(); String response_file = uploadfile.setup(filetobeuploaded, locationonserver); if (response_file == "success") { Console.Write("** File successfully uploaded **\n \n"); MyLogFile.WriteLog(username + "File successfully uploaded " + filetobeuploaded); } else { Console.Write("Could not Upload file.\n" + response_file + "\n"); MyLogFile.WriteLog(username + " could not upload file " + filetobeuploaded + " - " + response_file); MyAnswer = true; break; } MyAnswer = false; break; case "1": //File download Console.WriteLine(" You choose 1, download File\n"); Console.WriteLine("Please Enter the file to download:"); string f = Console.ReadLine(); if (String.IsNullOrEmpty(f)) { Console.WriteLine("File cannot be empty\n"); break; } Console.WriteLine("Please Enter The Local Directory to Download the file to: "); string l = Console.ReadLine(); if (String.IsNullOrEmpty(l)) { Console.WriteLine("Download Location cannot be empty\n"); break; } FileDownload RemoteFileDownload = new FileDownload(conn); String response4 = RemoteFileDownload.FileDownloadFromRemote(conn, f, l); if (response4 == "success") { Console.Write("File downloaded!\n"); MyLogFile.WriteLog(username + "downloaded file"); } else { Console.Write("Error: Could not download file.\n" + response4 + "\n"); MyLogFile.WriteLog(username + " download file failed - " + response4); } MyAnswer = false; //File upload break; default: Console.WriteLine("\n That was not a valid input, Please try again \n"); MyAnswer = false; //File download break; } return(MyAnswer); } // end getResponce()
//刷新DLC public void RefreshDLC() { Config.Clear(); AllDirectory.Clear(); CopyDirectory.Clear(); IgnoreConstSet.Clear(); ConfigExtend.Clear(); ConfigAll.Clear(); EditorExtend.Clear(); EditorAll.Clear(); foreach (var item in BuildRule) { AddBuildConfig(item); } foreach (var item in IgnoreConst) { AddIgnoreConst(item); } //加载内部dlc ConfigInternal = new DLCItemConfig(Const.STR_InternalDLC); EditorInternal = new DLCItem(ConfigInternal); //加载原生dlc ConfigNative = new DLCItemConfig(Const.STR_NativeDLC); EditorNative = new DLCItem(ConfigNative); //加载其他额外DLC foreach (var item in DLC) { var dlcItem = new DLCItemConfig(item.Name); ConfigExtend.Add(dlcItem); EditorExtend.Add(new DLCItem(dlcItem)); } ConfigAll = new List <DLCItemConfig>(ConfigExtend); ConfigAll.Add(ConfigInternal); ConfigAll.Add(ConfigNative); EditorAll = new List <DLCItem>(EditorExtend); EditorAll.Add(EditorInternal); EditorAll.Add(EditorNative); #if UNITY_EDITOR if (!Application.isPlaying) { foreach (var item in AllDirectory) { FileUtil.EnsureDirectory(Path.Combine(Const.Path_NativeDLC, item)); } foreach (var item in DLC) { foreach (var dic in AllDirectory) { FileUtil.EnsureDirectory(Path.Combine(Const.Path_Bundles, item.Name, dic)); } } } #endif }
public DLCItem(DLCItemConfig config, AssetBundleManifest assetBundleManifest = null) { Config = config; Name = config.Name; IsActive = config.IsActive; ABManifest = assetBundleManifest; BuildRuleData.Clear(); CopyDirectory.Clear(); foreach (var item in DLCConfig.Config) { BuildRuleData.Add(item.Clone() as BuildRuleConfig); } CopyDirectory.AddRange(DLCConfig.CopyDirectory.ToArray()); //计算DLC的跟目录 AssetsRootPath = CalcAssetRootPath(Name); //计算出绝对路径(拷贝文件使用) AbsRootPath = Path.Combine(Application.dataPath, AssetsRootPath.Replace("Assets/", "")); //计算出目标路径 TargetPath = Path.Combine(Const.Path_StreamingAssets, Name); //计算Const路径 ConstPath = Path.Combine(Const.RPath_Resources, Const.Dir_Const, Name + "Const.cs"); //计算Manifest路径 if (IsEditorMode) { ManifestPath = Path.Combine(AssetsRootPath, Const.Dir_Config); } else { ManifestPath = Path.Combine(TargetPath, Const.Dir_Config); } //计算Config路径 if (IsEditorMode) { ConfigPath = Path.Combine(AssetsRootPath, Const.Dir_Config); } else { ConfigPath = Path.Combine(TargetPath, Const.Dir_Config); } //计算语言包路径 if (IsEditorMode) { LanguagePath = Path.Combine(AssetsRootPath, Const.Dir_Language); } else { LanguagePath = Path.Combine(TargetPath, Const.Dir_Language); } //计算lua路径 if (IsEditorMode) { LuaPath = Path.Combine(AssetsRootPath, Const.Dir_Lua); } else { LuaPath = Path.Combine(TargetPath, Const.Dir_Lua); } //计算Text路径 if (IsEditorMode) { TextPath = Path.Combine(AssetsRootPath, Const.Dir_TextAssets); } else { TextPath = Path.Combine(TargetPath, Const.Dir_TextAssets); } //计算CS路径 if (IsEditorMode) { CSPath = Path.Combine(AssetsRootPath, Const.Dir_CSharp); } else { CSPath = Path.Combine(TargetPath, Const.Dir_CSharp); } //计算Excel路径 if (IsEditorMode) { ExcelPath = Path.Combine(AssetsRootPath, Const.Dir_Excel); } else { ExcelPath = Path.Combine(TargetPath, Const.Dir_Excel); } #region func GenerateCopyPath(); GeneralPath(); //建立拷贝路径 void GenerateCopyPath() { AbsCopyDirectory.Clear(); if (CopyDirectory != null) { for (int i = 0; i < CopyDirectory.Count; ++i) { AbsCopyDirectory.Add(Path.Combine(AbsRootPath, CopyDirectory[i])); } } } //建立打包路径 void GeneralPath() { foreach (var item in BuildRuleData) { string tempRootPath = AssetsRootPath; if (!item.CustomRootPath.IsInv()) { tempRootPath = item.CustomRootPath; } item.FullSearchPath = tempRootPath + "/" + item.Name; } } #endregion }
public TriggerTask(FSSlaveDirectoryProvider parent, string source, string destination) { abandon = false; this.source = source; copyTask = new CopyDirectory(parent, source, destination); }
public TriggerTask(FSMasterDirectoryProvider parent, string source, string destination) { abandon = false; this.source = source; copyTask = new CopyDirectory(parent, source, destination, parent); }