コード例 #1
0
		private void getFilesInDir(clParam p, DirectoryInfo curDir)
		{
			try
			{
				if (backWorkFindFiles.CancellationPending)
					return;

				FileInfo[] files = curDir.GetFiles();
				for (int i = 0; i < files.Length; i++)
				{
					if (isGoodExtension(p, files[i]))
					{
						backWorkFindFiles.ReportProgress(2, new clData(files[i]));
					}
				}

				if (cntDirectory++ > 50)
				{
					cntDirectory = 0;
					backWorkFindFiles.ReportProgress(1, curDir.FullName.Substring(p.pathLength));
				}

				DirectoryInfo[] childDirectories = curDir.GetDirectories();
				for (int i = 0; i < childDirectories.Length; i++)
				{
					getFilesInDir(p, childDirectories[i]);
				}
			}
			catch (Exception ex)
			{
				GenFunc.LogAdd(ex);
			}

		}
コード例 #2
0
		private bool isGoodExtension(clParam p, FileInfo fileInfo)
		{
			try
			{
				for (int i = 0; i < p.extensionArr.Length; i++)
				{
					if (fileInfo.Extension == p.extensionArr[i])
						return true;
				}
				return false;
			}
			catch (Exception ex)
			{
				GenFunc.LogAdd(ex);
				return false;
			}
		}
コード例 #3
0
		private void backWorkFindFiles_DoWork(object sender, DoWorkEventArgs e)
		{
			try
			{
				clParam p = (clParam)e.Argument;
				DirectoryInfo curDir = new DirectoryInfo(p.path);
				if (!curDir.Exists)
				{
					backWorkFindFiles.ReportProgress(0, "Folder doen't exists");
					return;
				}

				getFilesInDir(p, curDir);
			}
			catch (Exception ex)
			{
				GenFunc.LogAdd(ex);
			}
		}
コード例 #4
0
		private void butStart_Click(object sender, EventArgs e)
		{
			try
			{
				if (!txtPath.Text.EndsWith("\\"))
				{
					txtPath.Text += "\\";
				}
				if (!txtBackFolder.Text.EndsWith("\\"))
				{
					txtBackFolder.Text += "\\";
				}

				if (butStart.Text == "Start")
				{
					bindingData.Clear();
					VideoTotalSize = 0;

					clParam p = new clParam();
					p.path = txtPath.Text;
					p.extension = txtExtension.Text;
					p.BackupPath = txtBackFolder.Text;
					clData.param = p;

					backWorkFindFiles.RunWorkerAsync(p);
					butStart.Text = "Cancel";
				}
				else
				{
					backWorkFindFiles.CancelAsync();
				}
			}
			catch (Exception ex)
			{
				GenFunc.LogAdd(ex);
			}
		}