|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Determine if a File existsI tried using the system.io.file.exists function, that will appears to locate the file if I use the complete filespec, when I move the project to the web server, that command will not work because I can not specify the entire path, just the path relative to the default project folder. Example This is the path my image property uses: "~/image/NoImageAvailable.jpg" If I use the above system.io.file.exists fails if I use the full filespec: " E:\Documents and Settings\Steve\My Documents\Visual Studio 2005\WebSites\GshockWatch\NoImageAvailable.jpg" If I use the above system.io.file.exists succeeds. You see how the second example would not work on an ISPs server. any suggestions. thanks steve Server.MapPath
Show quoteHide quote "Stephen E. Weber" <s*@webersystems.com> wrote in message news:eQYnD1nXGHA.1476@TK2MSFTNGP03.phx.gbl... >I need to determine if a file exists using code. > > I tried using the system.io.file.exists function, that will appears to > locate the file if I use the complete filespec, when I move the project to > the web server, that command will not work because I can not specify the > entire path, just the path relative to the default project folder. > > Example > > This is the path my image property uses: "~/image/NoImageAvailable.jpg" > > If I use the above system.io.file.exists fails > > if I use the full filespec: " E:\Documents and Settings\Steve\My > Documents\Visual Studio 2005\WebSites\GshockWatch\NoImageAvailable.jpg" > > If I use the above system.io.file.exists succeeds. > > You see how the second example would not work on an ISPs server. > > any suggestions. > thanks > steve > > Thanks for the tip, but in this case i dont think its gonna apply, I know
what the entire path of the file from the root is, which is what this command appears to return, I need a way to specify the path from the home folder on the web site, on most servers I dont have access to the full root and they differ, Im trying to use a path that will work on any server. thanks Show quoteHide quote "Jeff Dillon" <jeffdil***@hotmail.com> wrote in message news:ul63q3nXGHA.196@TK2MSFTNGP04.phx.gbl... > Server.MapPath > > "Stephen E. Weber" <s*@webersystems.com> wrote in message > news:eQYnD1nXGHA.1476@TK2MSFTNGP03.phx.gbl... >>I need to determine if a file exists using code. >> >> I tried using the system.io.file.exists function, that will appears to >> locate the file if I use the complete filespec, when I move the project >> to >> the web server, that command will not work because I can not specify the >> entire path, just the path relative to the default project folder. >> >> Example >> >> This is the path my image property uses: "~/image/NoImageAvailable.jpg" >> >> If I use the above system.io.file.exists fails >> >> if I use the full filespec: " E:\Documents and Settings\Steve\My >> Documents\Visual Studio 2005\WebSites\GshockWatch\NoImageAvailable.jpg" >> >> If I use the above system.io.file.exists succeeds. >> >> You see how the second example would not work on an ISPs server. >> >> any suggestions. >> thanks >> steve >> >> > > > That doesn't make any sense. Either server.mappath will give you the fully
qualified path, or simply a relative path from the root will always work too File.IO needs the fully qualified path. Jeff Show quoteHide quote "Stephen E. Weber" <s*@webersystems.com> wrote in message news:uV20tMwXGHA.128@TK2MSFTNGP05.phx.gbl... > Thanks for the tip, but in this case i dont think its gonna apply, I know > what the entire path of the file from the root is, which is what this > command appears to return, I need a way to specify the path from the home > folder on the web site, on most servers I dont have access to the full > root and they differ, Im trying to use a path that will work on any > server. > > thanks > > > "Jeff Dillon" <jeffdil***@hotmail.com> wrote in message > news:ul63q3nXGHA.196@TK2MSFTNGP04.phx.gbl... >> Server.MapPath >> >> "Stephen E. Weber" <s*@webersystems.com> wrote in message >> news:eQYnD1nXGHA.1476@TK2MSFTNGP03.phx.gbl... >>>I need to determine if a file exists using code. >>> >>> I tried using the system.io.file.exists function, that will appears to >>> locate the file if I use the complete filespec, when I move the project >>> to >>> the web server, that command will not work because I can not specify the >>> entire path, just the path relative to the default project folder. >>> >>> Example >>> >>> This is the path my image property uses: "~/image/NoImageAvailable.jpg" >>> >>> If I use the above system.io.file.exists fails >>> >>> if I use the full filespec: " E:\Documents and Settings\Steve\My >>> Documents\Visual Studio 2005\WebSites\GshockWatch\NoImageAvailable.jpg" >>> >>> If I use the above system.io.file.exists succeeds. >>> >>> You see how the second example would not work on an ISPs server. >>> >>> any suggestions. >>> thanks >>> steve >>> >>> >> >> >> > > "Stephen E. Weber" <s*@webersystems.com> wrote in message That's a Unix path definition. It means [HOME]/image/NoImageAvailable.jpgnews:eQYnD1nXGHA.1476@TK2MSFTNGP03.phx.gbl... > Example > > This is the path my image property uses: "~/image/NoImageAvailable.jpg" Thanks for the advise and information!
ok, that makes sense, I assume in Windows land I can use the ".." for current folder, do you know if there is a specification for home folder in windows land? thanks Steve "Homer J Simpson" <nob***@nowhere.com> wrote in message news:c%j%f.72479$%H.41820@clgrps13...Show quoteHide quote > > "Stephen E. Weber" <s*@webersystems.com> wrote in message > news:eQYnD1nXGHA.1476@TK2MSFTNGP03.phx.gbl... > >> Example >> >> This is the path my image property uses: "~/image/NoImageAvailable.jpg" > > That's a Unix path definition. It means [HOME]/image/NoImageAvailable.jpg > > > "Stephen E. Weber" <s*@webersystems.com> wrote in message Actually . is the current folder, .. is the parent (just like Unix -- which news:OTx0hFwXGHA.4484@TK2MSFTNGP02.phx.gbl... > Thanks for the advise and information! > > ok, that makes sense, I assume in Windows land I can use the ".." for > current folder, do you know if there is a specification for home folder in > windows land? Gates copied from) "Special' folders, like My Documents, do have specific .Net names. I've seen that question answered here before. However there is no real 'Home' folder in Dos/Windows etc. See "My.Computer.FileSystem.SpecialDirectories Object Members" and "My.Computer.FileSystem.SpecialDirectories Property" for the paths etc. /include/somepath/filename
will always be from the root of the virtual directory like c:\inetpub\wwwroot\vdir\include\sompath Jeff "Homer J Simpson" <nob***@nowhere.com> wrote in message news:c%j%f.72479$%H.41820@clgrps13...Show quoteHide quote > > "Stephen E. Weber" <s*@webersystems.com> wrote in message > news:eQYnD1nXGHA.1476@TK2MSFTNGP03.phx.gbl... > >> Example >> >> This is the path my image property uses: "~/image/NoImageAvailable.jpg" > > That's a Unix path definition. It means [HOME]/image/NoImageAvailable.jpg > > >
VC6 ATL DLL interop with VB.NET
All the king's horses and all the king's men....... How do I determine if a control has a specific property i need timer interval more than 1 Minute. Class Inheritance Connection to Access Db with a password? string value to new form instance? getting application version... Title Bar is visible Call control's event from a collection |
|||||||||||||||||||||||