Top Ad unit 728 × 90

random

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 "";
            }
        }


Get fileExtension/FileName/GetNewFileNameGUID from file in .net Reviewed by Vikas Kumar Singh on December 03, 2017 Rating: 5

No comments:

All Rights Reserved by DotNetBasic.com © 2019

Contact Form

Name

Email *

Message *

© 2018 All rights reserved by DotNetBasic. Powered by Blogger.