Get File Name From Path : File Name « File Stream « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# Book
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » File Stream » File NameScreenshots 
Get File Name From Path
     
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace PeDALS.Utilities
{
    public class FileHelper
    {
        public static string GetFileNameFromPath(string path)
        {
            string[] temp;
            temp = path.Split('/');
            return temp[temp.Length - 1].ToString();
        }

        public static string GetPathFromFileName(string path)
        {
            string fullPath="";
            string[] temp;
            temp = path.Split('\\');

            for (int i = 0; i < temp.Length - 1; i++)
            {
                if (i == 0)
                    fullPath = temp[i].ToString();
                else
                    fullPath = fullPath + "\\" + temp[i].ToString();
            }

            return fullPath;

        }

    }
}

   
    
    
    
    
  
Related examples in the same category
1.Query file name with Linq
2.Clean File Name
3.Retrieves the date from the beginning of the WinSat filename and creates a datetime object from it
4.Get File Name
5.Convert To Legal File Name
6.Extracts a path part of a full path filename, searching for the last directory separator or column.
7.Creates a relative path from absolute pathfilename and a reference path.
8.Get file extension
9.Restrict a list of files to valid extensions only
10.Get Content Type by Extension
11.Get Full Path Without Extension
12.Full Name Without Extension
13.Name Without Extension
14.ImageFormat to Extension
15.Gets the extension without the dot
16.Get Image Type Extension
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.