Solved

Server.Mappath equivalent in windows application

Posted on 2004-10-25
5,186 Views
Last Modified: 2008-01-09
Hi,
  iam using windows application. I have file named myfile.txt which can be located anywhere in my harddisk. I want to know whether there is anything equivalent in windows application for Server.Mappath to map to my file virtually.

Any furthur comments and suggestions are welcome.

Thanks in advance.
0
Question by:pradeepy
    8 Comments
     
    LVL 4

    Expert Comment

    by:Cnatra
    Try using this properties:

    // Init app dir
    Application.StartupPath

    // User dir
    Application.UserAppDataPath

    0
     
    LVL 15

    Expert Comment

    by:Timbo87
    You can use Environment.CurrentDirectory

    "Gets and sets the fully qualified path of the current directory; that is, the directory from which this process starts."
    0
     

    Author Comment

    by:pradeepy
    Hi Timbo87,
                 my file can be located anywhere in the harddrive. How do i get that
                 specific location.

    Thanks.
    0
     
    LVL 15

    Expert Comment

    by:Timbo87
    Do you mean you need to search the hard drive for that file?
    0
     

    Author Comment

    by:pradeepy
    Yes,
        is there a single command in console or windows application that retrives the full path of a file by specifying just the file name.

    Thank you.
    0
     
    LVL 15

    Accepted Solution

    by:
    No, you have to recursively search the hard drive for the file, which is taxing on the computer if you need to do it often.
    0
     

    Author Comment

    by:pradeepy
    Ok Timbo87 ,
            can you give that piece of code ahich searches for the file recursively.

    Thank You.
    0
     
    LVL 6

    Assisted Solution

    by:etmendz
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: JavaScript Coding - Massive 12-Part Bundle

    Regardless of your programming skill level, you'll go from basics to advanced concepts in a vast array of JavaScript subjects including Sammy.js, Agility.js, Ember.js, Node.js, jQuery, AJAX, Extjs, AngularJS, Knockout.js, and JSON.

    Article by: Ivo
    Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    913 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now