I have a WCF service which needs to read a file that sits in the same folder and I am not sure on how to get the file path.
Have tried: string filePath = Path.GetFullPath("T.sql"); which gives me something like C:\Program Files\IIS Express\T.SQL which is wrong.
What is the correct syntax to get the file path?
Try
HttpRuntime.AppDomainAppPath + "/T.sql";
Related
When I'm running my project in localhost I'm able to locate the file and process it further. This is achieved with this line of code.
path = Path.Combine(Directory.GetCurrentDirectory(), "EmailTemplates\\SuccessOrderWindows10.html");
I'm able to get the full relative path C:\etc\etc\etc.. But when i push this code to production, when it reaches to this stage, it throws an error
Error One or more occurred. (Could not find a part of the path 'h:\root\home\username\www\sitename\EmailTemplates\SuccessOrderWindows10.html'.)
What I'm doing wrong? Do i have to select the files and set them to content so that it will be included in the build?
Directory.GetCurrentDirectory will get the current working directory of the application.When you push the code to production,you change the the current working directory,so the relative path of your file will change,so you need to put the file to the new path h:\root\home\username\www\sitename\EmailTemplates\SuccessOrderWindows10.html when production.Or you can use absolute path.
Functionality-Uploading a file.
When I run my code to upload a file in AWS instance, absolute path of the file which I get is like /home/ec2-user/project/src/.../filename. If the script tries to upload the file to the application under test with above path I get file path is not absolute error. Any suggestion on this.
Thanks in advance.
I have deployed my web application in GlassFish server 3.0. When I execute it, I get an error: The system cannot find the file specified (MobileOntologyRev1.owl) , which is a file from which I read in my code (I haven't specified the absolute path for this file in my code, and simply refer it using the file name without any addtional path) . Where should this file be kept in order to access it? I have presently tried keeping it inside the WEB-INF/Classes folder and in the root dir of the application inside glassfish/domains/domain1/
Where should I place this file??
You may consider taking advantage of the FaceContext as mentioned below.
You can create a folder (repors) inside your WEB-INF for example.
String pathToFile=
FacesContext.getCurrentInstance().getExternalContext().getRealPath("/WEB-INF/reports/MobileOntologyRev1.owl");
I'm attempting to download metadata for a WCF service using svcutil but I'm running into issues with the /directory:<> parameter. The directory I want to save to has a space in it:
C:\Service References\Logging
so when I execute /t:metadata I receive the following error:
Error: The directory 'C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\References\Logging' could not be found. Verify that the directory exists and that you have the appropriate permissions to read it.
It looks to me like the space in "Service References" is causing the issue. From my understanding of command shell (which is very little) spaces act as delimiters for an executable. So I tried escaping the space with a carrot
Service^ References
and surrounding the path in double quotes
"C:\Service References\Logging"
but neither of those seem to be working, as the /directory: parameter doesn't recognize them as valid characters in the value. I haven't been able to find any direction in regards to this and svcutil, so I'm at a loss right now.
I could download the files to a temp folder and then move them, but I would prefer not to take that approach.
I would appreciate any direction that could be given on trying to resolve this.
Thanks in advance.
-- EDIT --
this is the full command that I'm trying to run. if you try it yourself, you'll have to add you're own WCF reference as this one is on an internal ip address
svcutil /t:metadata http://dev.taskservices.noelnet.com/LoggingService/LoggingService.svc /d:C:\Service References\Logging\
According to the documentation for svcutil
/directory: - Directory to create files in (default: current directory) (Short Form: /d)
Since the default is to use the current directory, let us change the current directory for the command.
pushd "C:\Service References\Logging\"
svcutil /t:metadata http://dev.taskservices.noelnet.com/LoggingService/LoggingService.svc
popd
If you do not need to revert back to the original directory you can just use cd "C:\Service References\Logging\".
Note, in order for this to work, svcutil must be called using its entire path or have its path listed in the PATH environment variable. This is what I mean by calling using its entire path:
cd "C:\Service References\Logging\"
"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\svcutil.exe" /t:metadata http://dev.taskservices.noelnet.com/LoggingService/LoggingService.svc
I have added some files that I need to be downloaded to the Application start up path. So I set Build Action as content now the files have been copied some where
C:\Documents and Settings\TestUser.ANNAM\Local Settings\Apps\2.0\Data\HVDRBMY5.8AA\858AT9VM.TNP\test..tion_2d7cfc137d9c2c74_0001.0013_432bd4561850d290\Data
How can access file from the application. My problem since it is a dynamic path will it be same folder count so that we can use like ....\Data\ Some think like this
You can use My.Application.Info.DirectoryPath this will return the directory where the application is stored.