We help IT Professionals succeed at work.

file extensions

1jaws
1jaws asked
on
if (RadAsyncUpload1.UploadedFiles.Count > 0)
            {

                foreach (UploadedFile file in RadAsyncUpload1.UploadedFiles)
                {
                    UploadedFileInfo uploadedFileInfo = new UploadedFileInfo(file);
here how can I get the just the name of the file, without the file extension of images?
}
Comment
Watch Question



just take a substring of the variable file (which is assume has your file path)
The following code should work:

string[] temp = file.split("\\");
string fileNameWithoutExt = temp[temp.Length -1].split(".")[0];

Open in new window


string fna = uploadedFileInfo.FileName;  will return the filename.

Then get filename without extension using the method GetFileNameWithoutExtension(). Please do refer the link:
http://msdn.microsoft.com/en-us/library/system.io.path.getfilenamewithoutextension(v=vs.71).aspx

Author

Commented:
I know to this link but I dont have a path just yet at this time....
Most Valuable Expert 2011
Top Expert 2015

Commented:
I know to this link but I dont have a path just yet at this time....
You don't need a full path to a file in order to use that function. You can pass it just a filename and get the extension only  = )
Most Valuable Expert 2011
Top Expert 2015

Commented:
...and get the extension only
Typo:  get the filename only.

Author

Commented:
ok, what would be the code for that because I cant get this to work...
Most Valuable Expert 2011
Top Expert 2015
Commented:
string fna = System.IO.Path.GetFilenameWithoutExtension(uploadedFileInfo.FileName);

Open in new window

Author

Commented:
Perfect. Thank you so much! for quick reply... I needed fast answer...Thanks others too...
Most Valuable Expert 2011
Top Expert 2015

Commented:
I think EaswaranP should be in on this solution as well. He pointed out the function; I just fit the syntax to your specific scenario  = )

Author

Commented:
Oppps.. I am soo sorry. Yes, you are right!! I 'll request a reopening the question

Author

Commented:
Swicth the Assistant Solution with Accepted Solution please..