c# - How to save filename only to the gridview but I need path while downloading the file -


In the end, how to download a file using the path but I was wondering how do I just file a file on grid view I can keep the full path to download.

On debugging I came to see that I can not name the file only on file uploads. Since this is done in the download section If I name the file, the file name is taken to the downloading part and the file is not downloaded.

Someone can help me

Code

  Upload private zones Attachachment (DataGridViewCell dgvCell) {(OpenFileDialog fileDialog = New OpenFileDialog ()) {// set file dialog property file file.Dialog.CheckFileExists = true; FileDialog.CheckPathExists = True; FileDialog.Filter = "all files | *. *"; FileDialog.Title = "Choose a file"; FileDialog.Multiselect = True; If (fileDialog.ShowDialog () == System.Windows.Forms.DialogResult.OK) {string strfilename = fileDialog.FileName; CncInfoDataGridView.Rows [dgvCell.RowIndex] .cel [1] .Value = strfilename; }}} /// & lt; Summary & gt; /// Download attachments from the provided DataGrid ViewCell /// & lt; / Summary & gt; /// & lt; Param name = "dgvcell" & gt; & Lt; / Param & gt; Private Virus DownloadAttachment (DataGridViewCell dgvCell) {string fileName = Convert. ToString (dgvCell.Value); If (! String.isnaloractic (filename)) {byte [] ozdata; FileInfo fileInfo = New FileInfo (fileName); String fileextension = fileinfo.exchange; // show (SaveFileDialog saveFileDialog1 = new SaveFileDialog ()) to show the dialog by using the Save Setup dialog box {SaveSaveDialog1.Filter = "Files (*" + fileExtension + "). *" + "+ FileExtension; SaveFileDialog1.Title = "Save File As"; SaveFileDialog1.CheckPathExists = True; SaveFileDialog1.FileName = fileName; If (saveFileDialog1.ShowDialog () == DialogResult.OK) {string s = cncInfoDataGridView.Rows [dgvCell.RowIndex] .cel [1] .Value.ToString (); ObjData = file. Read AllBytes (S); File. Type all the bits (saveFileDialog1.FileName, objData); }}}}}}  

Your question is not clear. But if I tell you right why do not you use a column for the file path and a hidden / 0 width column? Its a grid and therefore you can have many columns. Plus I'm thinking the code below should return the full path, unless you trim and can not see where you trim

  string strfilename = fileDialog.FileName;  

You can use the path only to get the file name

The above should return your file name only to check for better understanding.

Add another column and set the width to 0. Example below:

  Datagrid view column column = datagrid view. Column [0]; Column.Width = 0; CncInfoDataGridView.Columns.Add (column);  

Save your file path in new column width and retrieve it during download.

A similar question was asked here.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -