locked
Remove word and Update RRS feed

  • Question

  • User1208695299 posted

    Here i have one problem
     Ex: My file name "test.csv" so i need to send only test to DB... how to remove after test.. ??? in asp.net

    Thursday, June 19, 2014 6:54 AM

Answers

  • User-158764254 posted

    UserTSS

    My file name "test.csv" so i need to send only test to DB... how to remove after test

    To get the filename portion without the extension, you can use a built-in method of the Path class

    Dim justTheName As String = System.IO.Path.GetFileNameWithoutExtension("test.csv")

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 19, 2014 10:03 PM

All replies

  • User-718146471 posted

    You can use a replace command like this (at least as I best remember it):

    Filename = "test.csv";
    string namer = string.Empty;
    namer.replace (Filename, ".csv");

    Essentially, the value of namer will be "test" and that's it.  You could probably use a variety of methods to do this like a regex block.

    Thursday, June 19, 2014 7:06 AM
  • User-718146471 posted

    Oops, you wanted vb, no worries:

    Filename = "test.csv"
    Dim namer As String = String.Empty
    namer.replace(Filename, ".csv")
    

    Thursday, June 19, 2014 7:07 AM
  • User-492460945 posted
    string file = "test.csv";
    int index = file.ToString().IndexOf('.');
    string fName = file.ToString().Substring(0, index);

    VB

    Dim file As String = "test.csv"
    Dim index As Integer = file.ToString().IndexOf("."C)
    Dim fName As String = file.ToString().Substring(0, index)

    Check this once..

    Thursday, June 19, 2014 7:22 AM
  • User-158764254 posted

    UserTSS

    My file name "test.csv" so i need to send only test to DB... how to remove after test

    To get the filename portion without the extension, you can use a built-in method of the Path class

    Dim justTheName As String = System.IO.Path.GetFileNameWithoutExtension("test.csv")

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 19, 2014 10:03 PM
  • User1208695299 posted

    Thank You mbanavige :) Its working...

    Friday, June 20, 2014 12:01 AM