protected void btnRename_Click(Object sender, EventArgs e) { try { if (strSecurity == "10" || strOwner == intProfile.ToString()) // If owner or share type is 'Edit' then allow else deny the operation { if (strType != "Folder") { System.IO.FileInfo oFile = new System.IO.FileInfo(strPath); if (oFile.Exists) { txtName.Text += strType; oFile.MoveTo(oFile.Directory.FullName + "\\" + txtName.Text); oFile.LastAccessTime = DateTime.Now; oFile.LastWriteTime = DateTime.Now; oCustomized.UpdateDocumentRepository(intDocId, txtName.Text, strType, GetVirtualPath(oFile.Directory.FullName + "\\" + txtName.Text)); } else { lblError.Text = "The file " + oFile.FullName + " does not exist"; } } else { DirectoryInfo oDir = new DirectoryInfo(strPath); if (oDir.Exists) { string strOldPath = oCustomized.GetDocumentRepository(intDocId, "path"); string strNewPath = GetVirtualPath(oDir.Parent.FullName + "\\" + txtName.Text); oDir.MoveTo(strNewPath); oDir.LastAccessTime = DateTime.Now; oDir.LastWriteTime = DateTime.Now; DataSet ds = oCustomized.GetDocumentRepositoryByParent(strOldPath); int intCount = 0; foreach (DataRow dr in ds.Tables[0].Rows) { int intId = Int32.Parse(dr["id"].ToString()); string strTemp1 = dr["path"].ToString(); string strTemp2 = dr["parent"].ToString(); if (intCount == 0) { oCustomized.UpdateDocumentRepository(intId, txtName.Text, "Folder", ""); } strTemp1 = strTemp1.Replace(strOldPath, strNewPath); strTemp2 = strTemp2.Replace(strOldPath, strNewPath); oCustomized.UpdateDocumentRepositoryParent(intId, strTemp2, strTemp1); intCount++; } } else { lblError.Text = "The directory " + oDir.FullName + " does not exist"; } } ClientScript.RegisterClientScriptBlock(typeof(Page), "redirect", "window.top.navigate(window.top.location);", true); } else { ClientScript.RegisterClientScriptBlock(typeof(Page), "msg", "alert('Access Denied !!');", true); } } catch (Exception exc) { txtName.Text = ""; lblError.Text = "Directory/File Rename Error: " + exc.Message; } }