Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Get fileExtension/FileName/GetNewFileNameGUID from file in .net

 public static String GetFileExtension(this string FileNameWithExtension)
        {
            try
            {
                return FileNameWithExtension.Substring(FileNameWithExtension.LastIndexOf('.') + 1);
            }
            catch (Exception)
            {
                return "";
            }
        }
















//Get File Name when file with extension.

public static string GetFileName(this string FileNameWithExtension)
        {
            try
            {
                return FileNameWithExtension.Substring(0, FileNameWithExtension.LastIndexOf('.'));
            }
            catch (Exception)
            {
                return "";
            }
        }





  public static string GetNewFileNameGUID(this string FileNameWithExtension)
        {
            try
            {
                return (Guid.NewGuid().ToString() + "." + FileNameWithExtension.GetFileExtension());
            }
            catch (Exception)
            {
                return "";
            }
        }

Read more »


This post first appeared on Dot Net Tutorial For Beginners With Examples, please read the originial post: here

Share the post

Get fileExtension/FileName/GetNewFileNameGUID from file in .net

×

Subscribe to Dot Net Tutorial For Beginners With Examples

Get updates delivered right to your inbox!

Thank you for your subscription

×