Hello Everyone and thanks for your help in advance. I am
working on an application that uses as helper class to
determine if an image file exists. If the file exists,
the path to the image is returned. Otherwise, a "Picture
not found" path is returned. I have that part workin
well. However, I have developed this on a local machine
and want to push the class to my prosuction server.
However, the paths change from machine to machine. I
want to be able to find the fully qualified path to a
particular file or directory. I tried File.GetFullPat h
(myFilename), but that returns C:\WINDOWS\syst em32
\myFilename which is not where the file resides. I want
to make this as dynamic as possible. Any help would be
greatly appreciated. Thanks. 5 4663
If you have a specific number of files, I'd seriously
consider adding them as embedded resources. To do this,
go to VS.nET and Add Existing ITem and point to the
file. This will add it in comiled form to your project.
Just make sure you set it's build property to Embedded
Resource. If you do this, it will always exist.
I'm not sure about the other part though. Why would it
exist on some machines and not others? Will it/SHould it
always exist locally or are you going to reference a
network share for instance. You can't hit a specific
device name with either FileInfo or Path classes, but I
think the path class may get what you want ..although if
you could show me a in depth example I'm sure we can
figure it out. http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpref/html/frlrfsystemiopa thclasstopic.as p
Let me know.
Bill -----Original Message----- Hello Everyone and thanks for your help in advance. I
amworking on an application that uses as helper class to determine if an image file exists. If the file exists, the path to the image is returned. Otherwise,
a "Picturenot found" path is returned. I have that part workin well. However, I have developed this on a local machine and want to push the class to my prosuction server. However, the paths change from machine to machine. I want to be able to find the fully qualified path to a particular file or directory. I tried File.GetFullPat h (myFilename) , but that returns C:\WINDOWS\syst em32 \myFilename which is not where the file resides. I want to make this as dynamic as possible. Any help would be greatly appreciated. Thanks. .
The reason the paths will be different from machine to
machine is test machine (laptop) versus production
webserver. When I use the File.GetFullPat h
(myFilename), it returns C:\WINDOWS\syst em32
\myFilename which is not where the file physically
exists. Why is this? -----Original Message----- If you have a specific number of files, I'd seriously consider adding them as embedded resources. To do this, go to VS.nET and Add Existing ITem and point to the file. This will add it in comiled form to your
project.Just make sure you set it's build property to Embedded Resource. If you do this, it will always exist.
I'm not sure about the other part though. Why would it exist on some machines and not others? Will it/SHould
italways exist locally or are you going to reference a network share for instance. You can't hit a specific device name with either FileInfo or Path classes, but I think the path class may get what you want ..although if you could show me a in depth example I'm sure we can figure it out.
http://msdn.microsoft.com/library/default.asp? url=/library/en- us/cpref/html/frlrfsystemiopa thclasstopic.as p
Let me know.
Bill-----Original Message----- Hello Everyone and thanks for your help in advance. I amworking on an application that uses as helper class to determine if an image file exists. If the file exists, the path to the image is returned. Otherwise, a "Picturenot found" path is returned. I have that part workin well. However, I have developed this on a local machine and want to push the class to my prosuction server. However, the paths change from machine to machine. I want to be able to find the fully qualified path to a particular file or directory. I tried File.GetFullPat h (myFilename ), but that returns C:\WINDOWS\syst em32 \myFilename which is not where the file resides. I
wantto make this as dynamic as possible. Any help would be greatly appreciated. Thanks. . .
Hi Hugh,
You said:
|| I tried File.GetFullPat h (myFilename), but that returns
|| "C:\WINDOWS\sys tem32\myFilenam e" which is not where the file
resides
There isn't a File.GetFullPat h(). But there is Path.GetFullPat h() which
creates a path using the current directory. Which is not where the file
resides!
You need to obtain the FileInfo for "myFilename " and use
oFileInfo.FullP ath().
Obtaining the FileInfo is left as an exercise.
Regards,
Fergus
>Hello Everyone and thanks for your help in advance. I am working on an application that uses as helper class to determine if an image file exists. If the file exists, the path to the image is returned. Otherwise, a "Picture not found" path is returned.
How about this:
public string GetImagePath(st ring aImageFileName)
{
if(File.Exists( aImageFileName)
{
return Path.GetDirecto ryName(aImageFi leName)
}
else
{
return "Picture not found"
}
}
The "Path" class is in the System.IO namespace.
Marc
=============== =============== =============== =============== ====
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)i nova.ch
If the file is supposed to be in the same directory as the application, then
you could do something like this.
string path = Assembly.GetExe cutingAssembly( ).Location;
string fullName = Path.Combine(pa th,imageFile);
if ( File.Exists(ful lName) )
{
}
"Hugh McLaughlin" <hu**@kmcnetwor k.com> wrote in message
news:00******** *************** *****@phx.gbl.. . Hello Everyone and thanks for your help in advance. I am working on an application that uses as helper class to determine if an image file exists. If the file exists, the path to the image is returned. Otherwise, a "Picture not found" path is returned. I have that part workin well. However, I have developed this on a local machine and want to push the class to my prosuction server. However, the paths change from machine to machine. I want to be able to find the fully qualified path to a particular file or directory. I tried File.GetFullPat h (myFilename), but that returns C:\WINDOWS\syst em32 \myFilename which is not where the file resides. I want to make this as dynamic as possible. Any help would be greatly appreciated. Thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Philip Ronan |
last post by:
OK, here's my 2p worth:
===
Q. Why am I getting the error message 'Headers already sent'?
A. PHP produces this error message when you try to set a header for a web
page after you have already started sending out the content of the page.
Web content is always delivered with a few headers at the top, ending with a
blank line. For...
|
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...
|
by: orit |
last post by:
I have the following xml file:
<?xml version="1.0" encoding="utf-8" ?>
<course id="2555" title="Developing Microsoft .NET Applications for Windows
(Visual C# .NET)" length="5 days"
source="http://www.microsoft.com/learning/syllabi/en-us/2555Afinal.mspx">
<module id="1" title="Introducing Windows Forms"
location="D:\Disk-C\Documents and...
|
by: dixie |
last post by:
I have been running some code from a form's on open event to run regedit if
a registry key does not exist in the registry. It has been working fine,
but I have had the path to the registry fix file hard coded into the VBA
like this.
RunReg = Shell("regedit.exe /s F:\MyFolder\SQLfix.reg", 0)
Now I wish to make this more generic and allow...
|
by: KarimL |
last post by:
Thanks for your advices...
but i need to get the Image height because i dynamically resize the height
of my webcontrol based on the image height.
More i just have the url (relative parth) to the the image but in design
time mode all variables concerning Server or Context
ar not set ! ...so I can't use MapPath function to obtain the physical...
| |
by: Praveen |
last post by:
Hi All,
I have made a webservice in C# and it works fine in my machine. I ran into a
crazy problem when I wanted to deploy it in windows 2003 server. I have run
"aspnet_regiis.exe -i" to make sure that the extensions for .asmx file etc
are in place. I am getting http 404 when I give the url for the asmx file.
the http error code is wrong...
|
by: ruju00 |
last post by:
I am getting an error in Login() method of the following class
FtpConnection
public class FtpConnection
{
public class FtpException : Exception
{
public FtpException(string message) : base(message){}
public FtpException(string message, Exception innerException) :
base(message,innerException){}
|
by: sags |
last post by:
Hi ,
Iam a new uesr of this group.
I have a small doubt . Iam using the code mentioned below to retrive
the data from tab delimited text file ., but Iam getting all the
columns of the text file in one data grid column.
Dim file As String = "test.txt"
Dim path As String = "C:\"
Dim ds As New DataSet("Textfiles")
|
by: Hitesh |
last post by:
Hi,
I have a small script here that goes to inside dir and sorts the file
by create date. I can return the create date but I don't know how to
find the name of that file...
I need file that is not latest but was created before the last file.
Any hints... I am newbiw python dude and still trying to figure out lot
of 'stuff'..
|
by: Aaron Gray |
last post by:
Has anyone got a code snippet to separate out the path components, ie drive,
path, filename, and extension ?
Many thanks in advance,
Aaron
|
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. ...
| |
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |