Dev2.PathOperations.Dev2ActivityIOPathUtils.ExtractFileName C# (CSharp) Method

ExtractFileName() public static method

Extract the file name from the URI
public static ExtractFileName ( string path ) : string
path string
return string
        public static string ExtractFileName(string path)
        {
            string result;

            try
            {
                if(!IsDirectory(path))
                {
                    Uri uri = new Uri(path);
                    result = Path.GetFileName(uri.LocalPath);
                }
                else
                {
                    Uri uri = new Uri(path);
                    result = Path.GetFileName(uri.LocalPath);
                }
            }
            catch(Exception)
            {
                result = path;
            }

            return result;
        }

Usage Example

示例#1
0
 bool PerformTransfer(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst, IDev2CRUDOperationTO args, string origDstPath, IActivityIOPath p, bool result)
 {
     try
     {
         if (dst.PathIs(dst.IOPath) == enPathType.Directory)
         {
             var cpPath =
                 ActivityIOFactory.CreatePathFromString(
                     $"{origDstPath}{dst.PathSeperator()}{Dev2ActivityIOPathUtils.ExtractFileName(p.Path)}",
                     dst.IOPath.Username,
                     dst.IOPath.Password, true, dst.IOPath.PrivateKeyFile);
             var path = cpPath.Path;
             DoFileTransfer(src, dst, args, cpPath, p, path, ref result);
         }
         else
         {
             if (args.Overwrite || !dst.PathExist(dst.IOPath))
             {
                 var tmp  = origDstPath + @"\\" + Dev2ActivityIOPathUtils.ExtractFileName(p.Path);
                 var path = ActivityIOFactory.CreatePathFromString(tmp, dst.IOPath.Username, dst.IOPath.Password, dst.IOPath.PrivateKeyFile);
                 DoFileTransfer(src, dst, args, path, p, path.Path, ref result);
             }
         }
     }
     catch (Exception ex)
     {
         Dev2Logger.Error(ex, GlobalConstants.WarewolfError);
     }
     return(result);
 }
All Usage Examples Of Dev2.PathOperations.Dev2ActivityIOPathUtils::ExtractFileName