You must Sign In to post a response.
  • Category: Visual Studio

    How to separate the filename in using c3

    I am retrieving the drafts folder file name from c folder.

    In c folder file as follows

    for retrieving the filename code as follows in

    Dim strpath As String = "C:\Drafts\"
    Foldername = Directory.GetFiles(strpath, "*", SearchOption.TopDirectoryOnly)

    When i run and debug in foldername path as follows


    i have one label in that label i want to store the AFF name.
    after 2nd backslash AFF is there.
    i want to retrieve AFF after 2nd slash AFF is there.

    From the above path how to get AFF name after Back Slash.

    for that how can i write the code in

    Narasiman P.
  • #753887
    I am confused. Do you want to read the file name or only the name without slash. the Question is not clear can u please explain what is the exact requirement.

    What do you want to read and from where?

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #753896
    Hai Narasiman,
    You can use the below code snippet(in C#) to get the file names from the folder:

    using System;
    using System.IO;

    namespace DemoApp
    class Program
    static void Main(string[] args)
    string strpath = @"C:\Program Files\DVD Maker\";
    string[] files = Directory.GetFiles(strpath, "*", SearchOption.TopDirectoryOnly);
    foreach (var file in files)

    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • #753898
    Below is just the example:

    Dim s As String = "C:\Drafts\AFF.htm"
    Dim value As String = s.Substring(s.LastIndexOf("\") + 1)

    please modify it as per your requirement.

    Here from the string s we are getting the last index of the \ character and from the position one more than that we are extracting the remaining string and assigning it to the value variable,

    Miss. Jain
    Microsoft Certified Technology Specialist in .Net

  • Sign In to post your comments