示例#1
0
        private void btnCopyFile_Click(object sender, EventArgs e)
        {
            fileop fop = new fileop();
            datas  dd  = new datas();

            dd.setss(@"k:\video\SB.mp4");
            dd.setsd(@"d:\SB.mp4");
            Thread fct = new Thread(new ParameterizedThreadStart(fop.fcopy));

            fct.Start(dd);
        }
示例#2
0
        internal static bool PerformFileOperation(fileop operation, out string errorMsg)
        {
            errorMsg = null;
            try {
                operation();
                return(true);
            } catch (ArgumentException) {
                errorMsg = "Invalid file path";
            } catch (PathTooLongException) {
                errorMsg = "Path too long";
            } catch (DirectoryNotFoundException) {
                errorMsg = "Directory not found";
            } catch (IOException) {
                errorMsg = "An IO error occurred.";
            } catch (UnauthorizedAccessException) {
                errorMsg = "Unsupported operation or insufficient permissions";
            } catch (NotSupportedException) {
                errorMsg = "Invalid path format";
            } catch (SecurityException) {
                errorMsg = "Insufficient permissions";
            }

            return(false);
        }