473,762 Members | 6,675 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting the full path of a folder.

I have a class library with a method called getpath(). I want to be able to get
the full path of a folder and write some files to the (my_files_dir)
folder. A console application
will use this class library. How can I do this so I wont have to hardcode
this path
in my getpath() method. Here is the path below.

"C:\Inetpub\www root\Web_mycont rol\my_Files_di r\"
--
Dotty
Jul 20 '06 #1
4 4070
Take a look at System.IO.Path. GetFullPath()

Andy

Dots wrote:
I have a class library with a method called getpath(). I want to be able to get
the full path of a folder and write some files to the (my_files_dir)
folder. A console application
will use this class library. How can I do this so I wont have to hardcode
this path
in my getpath() method. Here is the path below.

"C:\Inetpub\www root\Web_mycont rol\my_Files_di r\"
--
Dotty
Jul 20 '06 #2
Not really clear... For now my understanding is that you want to get the
path of the web application (but is this always Web_mycontrol\m y_Files_dir
under the web root) from a console application ?

What is your architecture ? If the console application is called by the web
application you could perhaps pass the path as a command line parameter...

If not, the simplest/more flexible could be to just use the application
config file to define this setting once for all.

--
Patrice

"Dots" <my*****@yahoo. coma écrit dans le message de news:
0F************* *************** **...icrosof t.com...
>I have a class library with a method called getpath(). I want to be able to
get
the full path of a folder and write some files to the (my_files_dir)
folder. A console application
will use this class library. How can I do this so I wont have to hardcode
this path
in my getpath() method. Here is the path below.

"C:\Inetpub\www root\Web_mycont rol\my_Files_di r\"
--
Dotty

Jul 20 '06 #3
To explain better, there is a path that my web application writes to and I want
to use the same path for my console application to dump files.

The console application is not called by the web application. Actually,
forget about the web application right now.

The path will always be the same
"C:\Inetpub\www root\Web_mycont rol\my_Files_di r\"
No changes at all.

I just want my console application to use a method in my class library called
getpath() to grab the path and dump files in the my_files_dir folder.

right now I have an app.config file with my console application which is this

<appSettings>
<add key ="ResultFileLoc ation" value ="/Web_mycontrol" />
</appSettings>

and at the begining of my getpath() method I have this
FileLocation = AppSettings("Re sultFileLocatio n")

Is this clear enough? Any clue?

--
Dotty
"Patrice" wrote:
Not really clear... For now my understanding is that you want to get the
path of the web application (but is this always Web_mycontrol\m y_Files_dir
under the web root) from a console application ?

What is your architecture ? If the console application is called by the web
application you could perhaps pass the path as a command line parameter...

If not, the simplest/more flexible could be to just use the application
config file to define this setting once for all.

--
Patrice

"Dots" <my*****@yahoo. coma écrit dans le message de news:
0F************* *************** **...icrosof t.com...
I have a class library with a method called getpath(). I want to be able to
get
the full path of a folder and write some files to the (my_files_dir)
folder. A console application
will use this class library. How can I do this so I wont have to hardcode
this path
in my getpath() method. Here is the path below.

"C:\Inetpub\www root\Web_mycont rol\my_Files_di r\"
--
Dotty


Jul 20 '06 #4
If you want to keep a virtual path, you'll need also to know the web site so
that the console app can resolve the physical path (IMO no clear benefit).
It could cause problem in special cases (for example you removed the site
but want to do a last process on those files with your console application,
resolving the path will become impossible once the web site is removed).

My personal preference would be just to put the full path in the application
configuration file (my logic is that this is a console application that
doesn't have to know what a web site is, its job is just to process files
stored at a given filesystem location).

--
Patrice

"Dots" <my*****@yahoo. coma écrit dans le message de news:
C3************* *************** **...icrosof t.com...
To explain better, there is a path that my web application writes to and I
want
to use the same path for my console application to dump files.

The console application is not called by the web application. Actually,
forget about the web application right now.

The path will always be the same
"C:\Inetpub\www root\Web_mycont rol\my_Files_di r\"
No changes at all.

I just want my console application to use a method in my class library
called
getpath() to grab the path and dump files in the my_files_dir folder.

right now I have an app.config file with my console application which is
this

<appSettings>
<add key ="ResultFileLoc ation" value ="/Web_mycontrol" />
</appSettings>

and at the begining of my getpath() method I have this
FileLocation = AppSettings("Re sultFileLocatio n")

Is this clear enough? Any clue?

--
Dotty
"Patrice" wrote:
>Not really clear... For now my understanding is that you want to get the
path of the web application (but is this always
Web_mycontrol\ my_Files_dir
under the web root) from a console application ?

What is your architecture ? If the console application is called by the
web
application you could perhaps pass the path as a command line
parameter...

If not, the simplest/more flexible could be to just use the application
config file to define this setting once for all.

--
Patrice

"Dots" <my*****@yahoo. coma écrit dans le message de news:
0F************* *************** **...icrosof t.com...
>I have a class library with a method called getpath(). I want to be able
to
get
the full path of a folder and write some files to the (my_files_dir)
folder. A console application
will use this class library. How can I do this so I wont have to
hardcode
this path
in my getpath() method. Here is the path below.

"C:\Inetpub\www root\Web_mycont rol\my_Files_di r\"
--
Dotty



Jul 21 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5082
by: gwen | last post by:
Hi, I have a code to copy/move folders to a specified folder on the root drive - ie c:\stuff However, I also have the folder "stuff" on the root of other partitions as well - ie d:\stuff, e:\stuff, etc. I would like the code to work so that the selected folder for moving/copying will always go to the "stuff" folder of the drive that it is on. In other words, if a folder is selected on the d drive, it will be moved to d:\stuff, if it's...
3
3647
by: Kali K E | last post by:
Hi, I could not understand how I can do the following things in Python. Please help me. 1. First I have to find the current directory from where the script is invoked. 2. Next I have to form a directory structure there. If the current directory in step 1 is /home/mylogin, then from there I have to build a directory structure like /home/mylogin/result
0
1457
by: Bart Plessers \(artabel\) | last post by:
Hello From a dbase, I extract folder information with an ASP script. The records contain the full path of every folder like: folder\presentatie\project1 folder\details\project2 folder\details\project3 folder\details\project3\sub1 folder\details\project3\sub2
3
7709
by: Bill Brother | last post by:
Is it possible to retrieve the local full path of an image ( not the url )?
1
1540
by: Craig | last post by:
Hi I was wondering how to get the path that a DLL is running from (from a method within that DLL, e.g. it's own install path))? I have a web app with two modules. I'd like one of them to be able to read a file from the web app's bin directory (where the DLL is running from), but I can't find any information about how to get the path. The current folder returns the system32 folder, not the bin folder. Thanks for your help.
2
1165
by: RAB | last post by:
I tested my code on my local computer and it worked fine. When I uploaded it to my webserver at Godaddy.com, I get the following error... Exception Details: System.Data.OleDb.OleDbException: Operation must use an updateable query. The line of code with the error is: objCmd.ExecuteNonQuery
0
2851
by: smanisankar | last post by:
hi, the following is the full page code for uploading a file to server. since i got no idea to overwrite the file, i want delete the file if the file is already uploaded. i got the folder name and filename of the file to delete from the request.QueryString("path") so i got the above error when i try to delete the file before upload. Please anyone help me to solve out from this error. <%@ Import Namespace="System.IO" %>
4
29215
by: pedestrian via DotNetMonster.com | last post by:
I'm using VB 2005. How to get the full path for "Program Files" folder in Windows, ie. either it is C:\Program Files or D:\Program Files or etc.? How about the full path of "Windows" folder? (either C:\Windows or C:\WINNT etc.) Thanks for replying... --
0
876
by: mathewgk80 | last post by:
Hi all, I uploaded an image (the name of the image is image1) to a folder (the name of the folder is Images) in the solution explorer.The full path of the image is "c:\\Documents and Settings\\Name\\DeskTop\\Photo\\Images\image1". I would like to get the path of the image as "~\Images\image1" and store it in database. Please help me... Thanks and regards,
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10136
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9989
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9925
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3913
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.