This is a migrated thread and some comments may be shown as answers.

Rename temporary file in TemporaryFolder location

1 Answer 98 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Lynne
Top achievements
Rank 1
Lynne asked on 19 Mar 2013, 09:12 PM
I'm trying to rename the temporary file generated by RadAsyncUpload, but cannot find a property that contains the temporary file name value.  I thought there was a TemporaryFileName property on RadAsyncUpload which would allow me to do this, but I cannot find it.  Below is some basic code with my comments on what did not work.  Is it possible to rename the temporary file in the TemporaryFolder location before I move it to its final destination?  Thanks in advance.

 

 

 

if (RadAsyncUpload1.UploadedFiles.Count > 0)

 

{

 

 

 

//This is the actual file name of the selected file, not the temporary file name in the TemporaryFolder directory, so this didn't work.

 

 

 

string filename = Server.MapPath(RadAsyncUpload1.TemporaryFolder) + "\\" + RadAsyncUpload1.UploadedFiles[0].FileName;

string outputFileName = "MyNewFile.pdf";

 

 

 

string newFilename = Server.MapPath(RadAsyncUpload1.TemporaryFolder) + "\\" + outputFileName;

 

 

 

//Now rename the file in the TemporaryFolder directory. This is a property on RadAsyncUpload.  Failed because filename did not exist.

 

 

 

 

 

 

 

File.Move(filename, newFilename);

 

 

 

 

 

 

 

 

 

}

 

 

 

1 Answer, 1 is accepted

Sort by
0
Lynne
Top achievements
Rank 1
answered on 20 Mar 2013, 01:02 AM
I resolved this by using the following:

RadAsyncUpload1.UploadedFiles[0].SaveAs(newFilename, true);

 

Tags
AsyncUpload
Asked by
Lynne
Top achievements
Rank 1
Answers by
Lynne
Top achievements
Rank 1
Share this question
or