public int Delete(int Document_ID, string document_dir_path) { string dir_path = HttpContext.Current.Server.MapPath(document_dir_path); if (System.IO.Directory.Exists(dir_path)) { string _file = GetFile(Document_ID); if (_file != null || _file != string.Empty) { string file_path = dir_path + "/" + _file; if (System.IO.File.Exists(file_path)) { FileHandleClass file_handle = new FileHandleClass(); file_handle.deleteFile(_file, dir_path); } } } SqlCommand cmd = new SqlCommand("[Production].[Product_Documents_Delete]", con) { CommandType = CommandType.StoredProcedure, CommandTimeout = Settings.CommandTimeout }; cmd.Parameters.AddWithValue("@Document_ID", Document_ID); cmd.Parameters.Add(new SqlParameter("@o_return", SqlDbType.Int) { Direction = ParameterDirection.Output }); con.Open(); cmd.ExecuteNonQuery(); int retunvalue = (int)cmd.Parameters["@o_return"].Value; con.Close(); return(retunvalue); }
private void DeleteFile(string file_name, string dir_path) { if (Directory.Exists(dir_path)) { FileHandleClass file_handle_obj = new FileHandleClass(); file_handle_obj.deleteFile(file_name, dir_path); } }
private void DeleteMainImage(string file_name) { string _main_dir_img_path = Server.MapPath(main_image_dir); if (Directory.Exists(_main_dir_img_path)) { FileHandleClass file_handle_obj = new FileHandleClass(); file_handle_obj.deleteFile(file_name, _main_dir_img_path); } }
public int Delete(string userid, int idx, string front_dir_path, string main_dir_path) { string MainImage = string.Empty, ThumbImage = string.Empty; string[] array_list = new string[2]; array_list = GetFrontMainImages(idx); MainImage = array_list[0]; ThumbImage = array_list[1]; FileHandleClass file_obj = new FileHandleClass(); if (ThumbImage != string.Empty) { file_obj.deleteFile(ThumbImage, front_dir_path); } if (MainImage != string.Empty) { file_obj.deleteFile(MainImage, main_dir_path); } SqlCommand cmd = new SqlCommand("[Articles].[sp_Articles_Delete]", con) { CommandType = CommandType.StoredProcedure, CommandTimeout = Settings.CommandTimeout }; cmd.Parameters.AddWithValue("@userid", userid); cmd.Parameters.AddWithValue("@ip", ip); cmd.Parameters.AddWithValue("@idx", idx); cmd.Parameters.Add(new SqlParameter("@o_return", SqlDbType.Int) { Direction = ParameterDirection.Output }); con.Open(); cmd.ExecuteNonQuery(); int retunvalue = (int)cmd.Parameters["@o_return"].Value; con.Close(); return(retunvalue); }
private void DeleteMediaFile(string file_name, int topicid) { int TypeId = Convert.ToInt32(ddlMediaTypeList.SelectedValue); MediaTypes media_type_obj = new MediaTypes(); Media_Types type_obj = media_type_obj.GetDetails(TypeId); string TypePath = type_obj.TypePath; string dir_path = Server.MapPath("~" + TypePath + "/" + topicid); if (Directory.Exists(dir_path)) { FileHandleClass file_handle_obj = new FileHandleClass(); file_handle_obj.deleteFile(file_name, dir_path); } }
private void DeleteMainImage(string Orginal_main_image) { string[] result = new string[2]; result = getDirectionFromFile(Orginal_main_image); string main_image = upload_main_image_dir + "/" + result[0]; string filename = result[1].ToString(); string _main_dir_img_path = Server.MapPath(main_image); if (Directory.Exists(_main_dir_img_path)) { FileHandleClass file_handle_obj = new FileHandleClass(); file_handle_obj.deleteFile(filename, _main_dir_img_path); } }
private int UpdateData() { string UserId = Session["UserId"].ToString(); int TypeId = Convert.ToInt32(ddlMediaTypeList.SelectedValue); string TopicName = txtTopicName.Text; string Description = txtDescription.Text; string Status = rdlStatus.SelectedValue; int ParentId = Convert.ToInt32(ddlMediaTopicList.SelectedValue); /*** UPLOAD ************************************************************************************************************/ string[] FileImg = new String[2]; string Photo = string.Empty; string front_path = Server.MapPath(upload_front_image_dir); string orginal_filename = ViewState["Photo"].ToString(); HttpPostedFile myfile = myFile.PostedFile; if (myfile.ContentLength > 0) { if (System.IO.Directory.Exists(front_path)) { FileHandleClass file_obj = new FileHandleClass(); Photo = file_obj.uploadFixedInputFile(myfile, front_path, 120, 120); file_obj.deleteFile(orginal_filename, front_path); } else { string scriptCode = "<script>alert('Đường dẫn không tồn tại.');</script>"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode); } } else { Photo = ViewState["Photo"].ToString(); } ////======================================================================================================================== MediaTopics media_topic_obj = new MediaTopics(); int i = media_topic_obj.Update(UserId, TypeId, _idx, ParentId, TopicName, Photo, Description, Status); return(i); }