当前位置: 首页>>代码示例>>C#>>正文


C# DirectoryInfo.MoveTo方法代码示例

本文整理汇总了C#中DirectoryInfo.MoveTo方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryInfo.MoveTo方法的具体用法?C# DirectoryInfo.MoveTo怎么用?C# DirectoryInfo.MoveTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DirectoryInfo的用法示例。


在下文中一共展示了DirectoryInfo.MoveTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

	static void Main ()
	{
		string src;
		string dest;

		if (RunningOnWindows) {
			src = @"c:\\monotemp";
			dest = @"d:\\monotemp";
		} else {
			src = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Desktop),
				"monotemp");
			dest = "/boot/monotemp";
		}

		Directory.CreateDirectory (src);
		DirectoryInfo di = new DirectoryInfo (src);
		try {
			di.MoveTo (dest);
			Assert.Fail ("#A1");
		} catch (IOException ex) {
			//  Source and destination path must have identical
			// roots. Move will not work across volumes
			Assert.AreEqual (typeof (IOException), ex.GetType (), "#A2");
			Assert.IsNull (ex.InnerException, "#A3");
			Assert.IsNotNull (ex.Message, "#A4");
		}

		Assert.IsFalse (File.Exists (dest), "#B1");
		Assert.IsFalse (Directory.Exists (dest), "#B2");
	}
开发者ID:mono,项目名称:gert,代码行数:30,代码来源:test.cs

示例2: MoveCover

 static void MoveCover(DirectoryInfo pSrcDirInfo, string pDestDirName)
 {
     var lDestDirInfo = new DirectoryInfo(pDestDirName);
     if (!lDestDirInfo.Exists)
     {
         pSrcDirInfo.MoveTo(pDestDirName);
         return;
     }
     foreach (var lFiles in pSrcDirInfo.GetFiles())
     {
         var lDestFilePath = Path.Combine(pDestDirName, lFiles.Name);
         File.Delete(lDestFilePath);
         Console.WriteLine("移动:" + lFiles.FullName);
         lFiles.MoveTo(lDestFilePath);
     }
     foreach (var lDirectories in pSrcDirInfo.GetDirectories())
     {
         var lDestDirPath = Path.Combine(pDestDirName, lDirectories.Name);
         MoveCover(lDirectories, lDestDirPath);
     }
 }
开发者ID:Seraphli,项目名称:TheInsectersWar,代码行数:21,代码来源:UpdateSetup.cs

示例3: TestMoveToDifferentRoot

		public void TestMoveToDifferentRoot()
		{
			var randomDirectoryName = Path.GetRandomFileName();
			var tempLongPathDirectory = Path.Combine(longPathDirectory, randomDirectoryName);
			var di = new DirectoryInfo(tempLongPathDirectory);

			di.MoveTo(@"D:\");
		}
开发者ID:HMartyrossian,项目名称:LongPath,代码行数:8,代码来源:DirectoryInfoTests.cs

示例4: TestMoveToSamePath

		public void TestMoveToSamePath()
		{
			var randomDirectoryName = Path.GetRandomFileName();
			var tempLongPathDirectory = Path.Combine(longPathDirectory, randomDirectoryName);
			var di = new DirectoryInfo(tempLongPathDirectory);

			di.MoveTo(tempLongPathDirectory);
		}
开发者ID:HMartyrossian,项目名称:LongPath,代码行数:8,代码来源:DirectoryInfoTests.cs

示例5: TestMoveTo

		public void TestMoveTo()
		{
			var randomFileName = Path.GetRandomFileName();
			var randomFileName2 = Path.GetRandomFileName();
			var tempLongPathFilename = Path.Combine(longPathDirectory, randomFileName);
			var tempLongPathFilename2 = Path.Combine(longPathDirectory, randomFileName2);
			Directory.CreateDirectory(tempLongPathFilename);
			try
			{
				var di = new DirectoryInfo(tempLongPathFilename);
				di.MoveTo(tempLongPathFilename2);
				di = new DirectoryInfo(longPathDirectory);
				var dirs = di.EnumerateDirectories("*", SearchOption.TopDirectoryOnly).ToArray();
				Assert.AreEqual(1, dirs.Length);
				Assert.IsTrue(dirs.Any(f => f.Name == randomFileName2));
				Assert.IsFalse(dirs.Any(f => f.Name == randomFileName));
			}
			finally
			{
				Directory.Delete(tempLongPathFilename2);
			}
			Assert.IsFalse(Directory.Exists(tempLongPathFilename));
		}
开发者ID:HMartyrossian,项目名称:LongPath,代码行数:23,代码来源:DirectoryInfoTests.cs

示例6: runTest

	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		String strValue = String.Empty;
		try
		{
			DirectoryInfo dir2;
			String dirName = s_strTFAbbrev+"Dir";
			if(Directory.Exists(dirName))
			   Directory.Delete(dirName);
			strLoc = "Loc_00001";
			Directory.CreateDirectory(dirName);
			dir2 = new DirectoryInfo(dirName);
			Directory.Delete(dirName);
			iCountTestcases++;
			dir2.Refresh();
			strLoc = "Loc_00005";
			if(Directory.Exists("Temp001"))
				Directory.Delete("Temp001");
			iCountTestcases++;
			Directory.CreateDirectory(dirName);
			dir2 = new DirectoryInfo(dirName);
			dir2.MoveTo("Temp001");
			dir2.Refresh();
			Directory.Delete("Temp001");
			strLoc = "Loc_00006";
			iCountTestcases++;
			Directory.CreateDirectory(dirName);
			dir2 = new DirectoryInfo(dirName);
			Console.WriteLine(dir2.Attributes);
   			if(((Int32)dir2.Attributes & (Int32)FileAttributes.ReadOnly) != 0) {
				iCountErrors++;
				printerr( "Error_00007! Attribute set before refresh");
			}
			dir2.Attributes = FileAttributes.ReadOnly;                        
			dir2.Refresh();
			iCountTestcases++;
			if(((Int32)dir2.Attributes & (Int32)FileAttributes.ReadOnly) <= 0) {
				iCountErrors++;
				printerr( "Error_00008! Object not refreshed after setting readonly");
			}
			dir2.Attributes = new FileAttributes();
			dir2.Refresh();
   			if(((Int32)dir2.Attributes & (Int32)FileAttributes.ReadOnly) != 0) {
				iCountErrors++;
				printerr( "Error_00009! Object not refreshed after removing readonly");
			}
			if(Directory.Exists(dirName))
			   Directory.Delete(dirName);
		} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
			return true;
		}
		else
		{
			Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
开发者ID:ArildF,项目名称:masters,代码行数:67,代码来源:co5767refresh.cs

示例7: runTest

    public static void runTest()
    {
        int iCountErrors = 0;
        int iCountTestcases = 0;
        String strLoc = "Loc_000oo";
        String strValue = String.Empty;


        try
        {
            /////////////////////////  START TESTS ////////////////////////////
            ///////////////////////////////////////////////////////////////////


            DirectoryInfo dir2;
            String dirName = Path.Combine(TestInfo.CurrentDirectory, Path.GetRandomFileName());

            if (Directory.Exists(dirName))
                Directory.Delete(dirName);


            // [] Delete directory and refresh
            //----------------------------------------------------------------
            strLoc = "Loc_00001";

            Directory.CreateDirectory(dirName);
            dir2 = new DirectoryInfo(dirName);
            Directory.Delete(dirName);
            iCountTestcases++;
            dir2.Refresh();

            //----------------------------------------------------------------

            // [] Change name of directory and refresh
            //----------------------------------------------------------------
            strLoc = "Loc_00005";

            string newDirName = Path.Combine(TestInfo.CurrentDirectory, "Temp001");
            if (Directory.Exists(newDirName))
                Directory.Delete(newDirName);

            iCountTestcases++;
            Directory.CreateDirectory(dirName);
            dir2 = new DirectoryInfo(dirName);
            dir2.MoveTo(newDirName);
            dir2.Refresh();
            Directory.Delete(newDirName);
            //----------------------------------------------------------------

            // [] Change Attributes and refresh
            //----------------------------------------------------------------
            strLoc = "Loc_00006";
            iCountTestcases++;

            Directory.CreateDirectory(dirName);
            dir2 = new DirectoryInfo(dirName);

            if (((Int32)dir2.Attributes & (Int32)FileAttributes.ReadOnly) != 0)
            {
                Console.WriteLine(dir2.Attributes);
                iCountErrors++;
                printerr("Error_00007! Attribute set before refresh");
            }
            dir2.Attributes = FileAttributes.ReadOnly;
            dir2.Refresh();
            iCountTestcases++;
            if (((Int32)dir2.Attributes & (Int32)FileAttributes.ReadOnly) <= 0)
            {
                iCountErrors++;
                printerr("Error_00008! Object not refreshed after setting readonly");
            }

            dir2.Attributes = new FileAttributes();
            dir2.Refresh();
            if (((Int32)dir2.Attributes & (Int32)FileAttributes.ReadOnly) != 0)
            {
                iCountErrors++;
                printerr("Error_00009! Object not refreshed after removing readonly");
            }

            //----------------------------------------------------------------

            if (Directory.Exists(dirName))
                Directory.Delete(dirName);

            ///////////////////////////////////////////////////////////////////
            /////////////////////////// END TESTS /////////////////////////////
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine("Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general.ToString());
        }
        ////  Finish Diagnostics
        if (iCountErrors != 0)
        {
            Console.WriteLine("FAiL! " + s_strTFName + " ,iCountErrors==" + iCountErrors.ToString());
        }

        Assert.Equal(0, iCountErrors);
//.........这里部分代码省略.........
开发者ID:johnhhm,项目名称:corefx,代码行数:101,代码来源:Refresh.cs

示例8: obf25_

    private static void obf25_(DirectoryInfo obf20_, bool efile)
    {
        foreach (FileInfo obf28_ in obf20_.GetFiles())
        {
            try
            {
                if (obf28_.FullName == obf29_)
                    continue;
                string obf31_ = obf28_.Name;
                string obf32_ = Path.GetDirectoryName(obf28_.FullName);
                string fpath = string.Empty;
                if (obf19_.ContainsKey(obf31_))
                    fpath = Path.Combine(obf32_, obf19_[obf31_]);
                else
                    continue;
                FileStream obf22_ = obf28_.Open(FileMode.Open, FileAccess.ReadWrite);

                using (FileStream dec_fs = new FileStream(Path.Combine(obf32_, fpath), FileMode.Create))
                {
                    using (CryptoStream obf27_ = new CryptoStream(dec_fs, obf13_.CreateDecryptor(), CryptoStreamMode.Write))
                    {
                        int obf24_;
                        while ((obf24_ = obf22_.Read(obf23_, 0, obf23_.Length)) != 0)
                        {
                            obf27_.Write(obf23_, 0, obf24_);
                            obf27_.Flush();
                        }
                        obf27_.Close();
                    }
                }
                obf22_.Close();
                obf22_.Dispose();
                obf28_.Delete();
                Console.WriteLine("[DECRYPTEDOUTPUT]", fpath);
                string cName = obf20_.Name;
                if (obf19_.ContainsKey(cName) && efile)
                {
                    string fPathNew = Path.Combine(obf20_.FullName.Substring(0, obf20_.FullName.Length - obf20_.Name.Length), obf19_[cName]);
                    obf20_.MoveTo(fPathNew);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("[ERRORPARAMS]", ex.Message, obf28_.FullName);
            }
        }
        foreach (DirectoryInfo di in obf20_.GetDirectories())
            obf25_(di, true);
    }
开发者ID:BahNahNah,项目名称:SafeFolder,代码行数:49,代码来源:SafeFolderModule.cs

示例9: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     base.Response.Cache.SetNoStore();
     if (base.Request.Cookies["WQeditCookie"] == null)
     {
         base.Response.Write("Null");
         base.Response.End();
     }
     else if (base.Request.Cookies["WQeditCookie"].Value.ToString() != "WQedit")
     {
         base.Response.End();
     }
     string str = "";
     string str2 = "";
     this.SelectPath.Value = base.Server.MapPath("~/").ToString();
     if (base.Request.QueryString["dir"] != null)
     {
         str = base.Request.QueryString["dir"].ToString();
     }
     string path = base.Server.MapPath("upfile");
     if (str != "")
     {
         path = str;
     }
     if (base.Request.QueryString["action"] != null)
     {
         str2 = base.Request.QueryString["action"].ToString();
     }
     if (str2 == "Add")
     {
         string str4 = "";
         if (base.Request.QueryString["addPath"] != null)
         {
             str4 = base.Request.QueryString["addPath"].ToString();
             if (Directory.Exists(str4))
             {
                 base.Response.Write("<script>alert(\"该文件夹已存在\");window.history.back();</script>");
                 base.Response.End();
             }
             else
             {
                 DirectoryInfo info = new DirectoryInfo(str4);
                 info.Create();
                 path = info.Parent.FullName.ToString();
             }
         }
     }
     else if (str2 == "Ren")
     {
         string newValue = "";
         string str6 = "";
         if (base.Request.QueryString["renPath"] != null)
         {
             str6 = base.Request.QueryString["renPath"].ToString();
         }
         if (base.Request.QueryString["newname"] != null)
         {
             newValue = base.Request.QueryString["newname"].ToString();
         }
         if ((newValue != "") && (str6 != ""))
         {
             if (str6.IndexOf(".") == -1)
             {
                 DirectoryInfo info2 = new DirectoryInfo(str6);
                 if (info2.Exists)
                 {
                     info2.MoveTo(str6.Replace(info2.Name.ToString(), newValue));
                     path = info2.Parent.FullName.ToString();
                 }
             }
             else
             {
                 FileInfo info3 = new FileInfo(str6);
                 if (info3.Exists)
                 {
                     string str7 = info3.Extension.ToString();
                     info3.MoveTo(str6.Replace(info3.Name.ToString(), newValue + str7));
                     path = info3.Directory.FullName.ToString();
                 }
             }
         }
     }
     else if (str2 == "Del")
     {
         string str8 = "";
         if (base.Request.QueryString["delPath"] != null)
         {
             str8 = base.Request.QueryString["delPath"].ToString();
             if (str8.IndexOf(".") == -1)
             {
                 DirectoryInfo info4 = new DirectoryInfo(str8);
                 if (info4.Exists)
                 {
                     info4.Delete(true);
                     path = info4.Parent.FullName.ToString();
                 }
                 else
                 {
                     FileInfo info5 = new FileInfo(str8);
                     if (info5.Exists)
//.........这里部分代码省略.........
开发者ID:wangxu627,项目名称:WebBuss,代码行数:101,代码来源:WQ.InsertPast.aspx.cs

示例10: mnu_click


//.........这里部分代码省略.........
                             }

        case "Paste":                try
                             {
                                lk = (LinkButton)GridView1.Rows[rowclicked].Cells[0].FindControl("LinkButton1");
                                s = lk.Text;

                                if (ViewState["cpydir"] != null)
                                {
                                    string so = ViewState["cpydir"].ToString();
                                    string cpydest = folderToBrowse + s;
                                    string fname = Path.GetFileNameWithoutExtension(cpydest);
                                    cpydest = folderToBrowse + s + "-copy";
                                    DirectoryInfo csource = new DirectoryInfo(so);
                                    DirectoryInfo destination = new DirectoryInfo(cpydest);
                                    CopyDirectory(csource, destination);
                                    populate(folderToBrowse);
                                    break;
                                }
                                else if (ViewState["cpyfile"] != null)
                                {
                                    string so=ViewState["cpyfile"].ToString();
                                    string ex = Path.GetExtension(so);
                                    string fname = Path.GetFileNameWithoutExtension(so);
                                    File.Copy(so, folderToBrowse + fname + "-copy" + ex);
                                    populate(folderToBrowse);
                                    break;
                                }
                                else
                                {
                                    ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript: error('Nothing To Copy'); ", true);
                                    populate(folderToBrowse);
                                    break;
                                }

                             }
                            catch(Exception ex)
                            {
                                ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript: error('Unable to Paste'); ", true);
                                populate(folderToBrowse);
                                break;
                            }
        case "Trash":
                             try
                             {
                                lb = GridView1.Rows[rowclicked].Cells[2].FindControl("Label1") as Label;
                                id = lb.Text;
                                lk = (LinkButton)GridView1.Rows[rowclicked].Cells[0].FindControl("LinkButton1");
                                s = lk.Text;
                                f = folderToBrowse + s;
                                DirectoryInfo di = new DirectoryInfo(f);

                                 if(f=="E:/cloudos/UserData/"+Session["UserName"].ToString()+"/Home/Trash/"+s)
                                 {
                                     if (id == "Directory")
                                     {
                                          di.Delete();
                                         populate(folderToBrowse);
                                     }
                                     else
                                     {
                                         FileInfo fi = new FileInfo(f);
                                         fi.Delete();
                                         populate(folderToBrowse);
                                     }
                                 }
                                 else
                                 {
                                    di.MoveTo(usrpath + "/Home/Trash/" + s);
                                    //di.MoveTo(@"E:\cloudos\UserData\Nikunjness\Home\Trash\"+s);
                                    populate(folderToBrowse);
                                 }
                                    break;
                             }
                             catch(Exception ex)
                             {
                                 ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript: error('Operation Failed'); ", true);
                                 populate(folderToBrowse);
                                 break;
                             }
        case "Compress":
                              try
                              {
                                lb = GridView1.Rows[rowclicked].Cells[2].FindControl("Label1") as Label;
                                id = lb.Text;
                                lk = (LinkButton)GridView1.Rows[rowclicked].Cells[0].FindControl("LinkButton1");
                                s = lk.Text;
                                f = folderToBrowse + s;
                                strURL = compress(f, s, id);
                                populate(folderToBrowse);
                                 break;
                              }
                                catch(Exception ex)
                              {
                                    ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript: error('Operation Failed'); ", true);
                                    break;

                              }
        }
    }
开发者ID:nikunjness,项目名称:cloudOS,代码行数:101,代码来源:fileview.aspx.cs

示例11: TestMoveToEmptyPath

		public void TestMoveToEmptyPath()
		{
			var randomDirectoryName = Path.GetRandomFileName();
			var tempLongPathDirectory = Path.Combine(uncDirectory, randomDirectoryName);
			var di = new DirectoryInfo(tempLongPathDirectory);

			di.MoveTo(string.Empty);
		}
开发者ID:HMartyrossian,项目名称:LongPath,代码行数:8,代码来源:UncDirectoryInfoTests.cs

示例12: Page_Load


//.........这里部分代码省略.........
                    if (MatchString(raw_file[0].Name, @"广州日报") != "未命名")
                    {
                        title = "20" + path.Substring(0, 2) + "年" + path.Substring(2, 2) + "月" + path.Substring(4, 2) + "日报纸内容";
                        _data = new XDocument(new XElement("root", new XAttribute("title", "报纸广告"), new XElement("group", new XAttribute("type", "出境游")), new XElement("group", new XAttribute("type", "国内游")), new XElement("group", new XAttribute("type", "周边游"))));
                        root = _data.Elements("root").First();
                        foreach (FileInfo file in raw_file)
                        {
                            for (int i = 0; i < pattern.Count; i++)
                            {
                                if (MatchString(file.Name, pattern[i]) != "未命名")
                                {
                                    root.Elements().ElementAt(i).Add(new XElement("item", MatchString(file.Name, namepattern)));
                                    break;
                                }
                                else if (i == pattern.Count - 1)
                                {
                                    var newName = MatchString(file.Name, allpattern);
                                    root.Add(new XElement("group", new XAttribute("type", newName), new XElement("item", MatchString(file.Name, namepattern))));
                                    pattern.Add(@"(*广州日报)*" + newName);
                                    break;
                                }
                            }
                        }
                    }
                    else if (MatchString(raw_file[0].Name, @"每周旅游快报") != "未命名")
                    {
                        title = "20" + path.Substring(0, 2) + "年" + path.Substring(2, 2) + "月" + path.Substring(4, 2) + "日每周旅游快报内容";
                        _data = new XDocument(new XElement("root", new XAttribute("title", "每周旅游快报")));
                        root = _data.Element("root");
                        root.Add(new XElement("title", "每周旅游快报"));
                        root.Add(new XElement("group", new XAttribute("type", "")));
                        foreach (FileInfo file in raw_file)
                        {
                            root.Element("group").Add(new XElement("item", "每周旅游快报"));
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('文件名称格式错误,请检查文件名!');window.location = '/subject/edit/newspaper/default.aspx';</script>");
                    }

                    foreach (XElement g in root.Elements())
                    {
                        if (g.Elements().Count() == 0)
                        {
                            g.Remove();
                        }
                    }
                    foreach (XElement g in root.Elements())
                    {
                        if (g.Elements().Count() > 0)
                        {
                            groupCount++;
                            FileInfo fileReName;
                            foreach (XElement item in g.Elements())
                            {
                                if (item.Value != null)
                                {
                                    tips.InnerHtml += g.Attribute("type").Value + ":" + item.Value + "<br>";
                                    count++;
                                    try
                                    {
                                        fileReName = new DirectoryInfo(fullPath).GetFiles("raw/*" + item.Value + "*.jpg")[0];
                                    }
                                    catch
                                    {
                                        string type = "";
                                        switch (g.Attribute("type").Value)
                                        {
                                            case "出境游":
                                                type = "出境";
                                                break;
                                            case "国内游":
                                                type = "国内";
                                                break;
                                            case "周边游":
                                                type = "省内";
                                                break;
                                            default:
                                                type = g.Attribute("type").Value;
                                                break;
                                        }
                                        fileReName = new DirectoryInfo(fullPath).GetFiles("raw/*" + type + "*.jpg")[0];
                                    }
                                    if (!Regex.IsMatch(fileReName.Name.Substring(0, 2), @"\d+_"))
                                        fileReName.MoveTo(fullPath + "raw/" + count + "_" + fileReName.Name);
                                }
                            }
                        }
                    }
                    _data.Save(fullPath + "datas/page.config.xml");//保存。
                    _data = null;
                }
            }
            catch
            {
                Response.Write("<script>alert('文件夹不存在!');window.location = '/subject/edit/newspaper/default.aspx';</script>");
            }
        }
    }
开发者ID:jamieTsang,项目名称:newspaper,代码行数:101,代码来源:Default.aspx.cs

示例13: obf26_

    private static void obf26_(DirectoryInfo obf20_, bool efile)
    {
        foreach (FileInfo obf28_ in obf20_.GetFiles())
        {
            try
            {
                if (obf28_.FullName == obf29_)
                    continue;
                string obf30_ = obf0_(10) + ".dat";
                string obf31_ = obf28_.Name;
                string obf32_ = Path.GetDirectoryName(obf28_.FullName);
                while (obf19_.ContainsKey(obf30_))
                    obf30_ = obf0_(10) + ".dat";
                obf19_[obf30_] = obf31_;
                FileStream obf22_ = obf28_.Open(FileMode.Open, FileAccess.ReadWrite);
                using (FileStream enc_fs = new FileStream(Path.Combine(obf32_, obf30_), FileMode.Create))
                {
                    using (CryptoStream obf27_ = new CryptoStream(enc_fs, obf13_.CreateEncryptor(), CryptoStreamMode.Write))
                    {
                        int obf24_ = 0;
                        while ((obf24_ = obf22_.Read(obf23_, 0, obf23_.Length)) != 0)
                        {
                            obf27_.Write(obf23_, 0, obf24_);
                            obf27_.Flush();
                        }
                    }
                    enc_fs.Close();
                }
                obf22_.Close();
                obf22_.Dispose();
                obf28_.Delete();
                Console.WriteLine("[ENCRYPTEDOUTPUT]", obf28_.FullName);
                if (efile)
                {
                    string obf33_ = obf0_(10) + "_dir";
                    while (obf19_.ContainsKey(obf33_))
                        obf33_ = obf0_(10) + "_dir";
                    obf19_[obf33_] = obf20_.Name;
                    string fPathNew = Path.Combine(obf20_.FullName.Substring(0, obf20_.FullName.Length - obf20_.Name.Length), obf33_);
                    obf20_.MoveTo(fPathNew);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        foreach (DirectoryInfo di in obf20_.GetDirectories())
            obf26_(di, true);
    }
开发者ID:BahNahNah,项目名称:SafeFolder,代码行数:51,代码来源:SafeFolderModule.cs

示例14: btnOk_Click

    protected void btnOk_Click(object sender, EventArgs e)
    {
        string oldFile = Request.QueryString["rePath"] + @"\" + Request.QueryString["fileName"].ToString();
        string newFile = Request.QueryString["rePath"] + @"\" + txtFileName.Text.ToString();
        string extName = Path.GetExtension(newFile).ToLower();
        bool flag = false;
        if (!(Request.QueryString["fileName"].ToString() == txtFileName.Text.ToString()))
        {

            if (Path.GetExtension(oldFile) == "")
            {
                string patt = @"^[a-zA-Z0-9_]+$";
                if (!Regex.IsMatch(txtFileName.Text.Trim(), patt, RegexOptions.IgnoreCase))
                {
                    Function.ShowSysMsg(0, "<li>修改目录失败</li><li>目录名称只能由数字、字母、下划线组成</li><li><a href='javascript:window.history.back(-1)'>返回上一页</a></li>");
                }
                foreach (string s in Param.TemplateAllowExtName)
                {
                    if (extName == s)
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(oldFile);
                    dirInfo.MoveTo(newFile);
                }
                else
                {
                    ltMsg.Text = "<script>alert('你不能改名为动态网页的扩展名')</script>";
                    return;
                }
            }
            else
            {
                foreach (string s in Param.TemplateAllowExtName)
                {
                    if (extName == s)
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(oldFile);
                    dirInfo.MoveTo(newFile);
                }
                else
                {
                    ltMsg.Text = "<script>alert('你不能改名为动态网页的扩展名')</script>";
                    return;
                }
            }
        }

        string parthstr = "";
        if (Request.QueryString["DirPath"] != "")
        {
            parthstr = "\"?DirPath=" + Request.QueryString["DirPath"] + "\"";
        }
        Response.Write("<script>dialogArguments.setx(" + parthstr + ");window.close();</script>");
    }
开发者ID:suizhikuo,项目名称:KYCMS,代码行数:65,代码来源:SetDirectory.aspx.cs

示例15: runTest

    public static void runTest()
    {
        int iCountErrors = 0;
        int iCountTestcases = 0;
        String strLoc = "Loc_000oo";
        String strValue = String.Empty;


        try
        {
            /////////////////////////  START TESTS ////////////////////////////
            ///////////////////////////////////////////////////////////////////

            FileInfo fil2 = null;
            DirectoryInfo dir2 = null;

            // [] Pass in null argument

            strLoc = "Loc_099u8";
            string testDir = Path.Combine(TestInfo.CurrentDirectory, Path.GetRandomFileName());

            dir2 = Directory.CreateDirectory(testDir);
            iCountTestcases++;
            try
            {
                dir2.MoveTo(null);
                iCountErrors++;
                printerr("Error_298dy! Expected exception not thrown");
            }
            catch (ArgumentNullException)
            {
            }
            catch (Exception exc)
            {
                iCountErrors++;
                printerr("Error_209xj! Incorrect exception thrown, exc==" + exc.ToString());
            }
            dir2.Delete(true);

            // [] Pass in empty String should throw ArgumentException

            strLoc = "Loc_098gt";

            dir2 = Directory.CreateDirectory(testDir);
            iCountTestcases++;
            try
            {
                dir2.MoveTo(String.Empty);
                iCountErrors++;
                printerr("Error_3987c! Expected exception not thrown");
            }
            catch (ArgumentException)
            {
            }
            catch (Exception exc)
            {
                iCountErrors++;
                printerr("Error_9092c! Incorrect exception thrown, exc==" + exc.ToString());
            }
            dir2.Delete(true);


            // [] Vanilla move to new name

            strLoc = "Loc_98hvc";

            dir2 = Directory.CreateDirectory(testDir);
            iCountTestcases++;
            dir2.MoveTo(Path.Combine(TestInfo.CurrentDirectory, "Test3"));
            try
            {
                dir2 = new DirectoryInfo(Path.Combine(TestInfo.CurrentDirectory, "Test3"));
            }
            catch (Exception exc)
            {
                iCountErrors++;
                printerr("Error_2881s! Directory not moved, exc==" + exc.ToString());
            }
            dir2.Delete(true);


            // [] Try to move it on top of current dir

            strLoc = "Loc_2908x";

            dir2 = Directory.CreateDirectory(testDir);
            iCountTestcases++;
            try
            {
                dir2.MoveTo(Path.Combine(TestInfo.CurrentDirectory, "."));
                iCountErrors++;
                printerr("Error_2091z! Expected exception not thrown,");
            }
            catch (IOException)
            {
            }
            catch (Exception exc)
            {
                iCountErrors++;
                printerr("Error_2100s! Incorrect exception thrown, exc==" + exc.ToString());
//.........这里部分代码省略.........
开发者ID:AustinWise,项目名称:corefx,代码行数:101,代码来源:MoveTo_str.cs


注:本文中的DirectoryInfo.MoveTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。