filepath

file path portability

I have a program that I need to run under *nix and windows. because the program takes file paths from files the issue is what to do about the \ vs / issue. My current thought is to put in a regex that converts the wrong one to the right one depending on what system I'm on. This will have the effect of letting either type work on either...

Dealing with relative filepaths in ASP.Net and Masterpages

This may be a painfully simply question for which I will be mocked but I am having difficulty in using filepaths in masterpages. I believe this is because if a page in a sub-directory to using the masterpage then the filepath is incorrect. To fix this I need to get the filepath from the root but I can't seem to get it working. I tried:...

Test for a syntactically correct path

In .NET is there a function that tests if a string is syntactically a correct path? I specifically don't want it to test if the path actually exists. my current take on this is a regex: ([a-zA-Z]:|\\)?\\?([^/\\:*?"<>|]+[/\\])*[^/\\:*?"<>|]* matches: c:\ bbbb \\bob/john\ ..\..\ rejects: xy: c:\\bob ...

C# Filepath Recasing

I'm trying to write a static member function in C# or find one in the .NET Framework that will re-case a file path to what the filesystem specifies. Example: string filepath = @"C:\temp.txt"; filepath = FileUtility.RecaseFilepath(filepath); // filepath = C:\Temp.TXT // Where the real fully qualified filepath in the NTFS volume is C:\T...

[Java] How to extract the file name from a file URI and create a link for the same?

My problem is :: From a string like "/usr/folder1/folder2/filename.ext" I have to extract out file name only for display (filename.ext only). My question would be how should I do it? Splitting on "/" and taking the last element is one way but doesn't smell nice to me. I have to create a hyperlink which uses URI of the file as the de...

Find the path of notepad.exe and mspaint.exe

What is the best way to find out where is notepad.exe and mspaint.exe that will work across various versions of Windows? Should I get the Windows directory via SHGetFolderPath(NULL, CSIDL_WINDOWS, NULL, SHGFP_TYPE_CURRENT, dir), and then traverse through all the subdirectories to look for the two files? (Assume that I am not interested...

How a servlet can get the absolute path to a file outside of the servlet?

We have been using System.getProperties("user.dir") to get the location of a properties file. Now that it has been deployed on Tomcat(via servlet), the System call is giving the location as tomcat and not at the location at where the properties file exist. How can we call the the properties file dynamically? Given: Tomcat is not t...

How to disable file input text box in IE?

Is it possible to prevent a user from typing in a file input text box in IE? The reason I ask is that if a user enters text that does not look like a file system path (eg. doesn't start with something like c:...) then when the user clicks the submit button nothing will happen. I would either like to not allow the user to type in the bo...

How to use a class for xml related logic taking xml file "uri" as initializer?

Hi , i have a project in which i created two classes TreeDisplay(Form.cs) and MytreeNode class in same namespace. TreeDisplay class contains all the GUI related stuff like Browse button textbox,label,progress bar and TReeView. I want the user to select a XML file through browse button which will be displayed in textbox.The Xml file sele...

iPhone App : Where do I put a config file ?

In my app, I have a simple ASCII file which stores some config info and other small info which it uses and changes. I want to copy that file to the iPhone with the app. 1) Please tell me where I should put this file (config.txt) in xcode. Should I put it under Resources ? 2) How will I access it in the iPhone ? Can I just use str =...

How to Set SSIS package dynamic .mdb connection When Running Package from .NET Application

Hello, I am currently working on a VB.NET desktop application that uses .mdb (Access) database files on the backend. The .mdb files are opened and edited in the VB.NET app. Once editing is completed, the users will need to import the data into our SQL Server database. This is an easy task, until you try to introduce the dynamic filepat...

How to get the filepath of files added to Windows Mobile app?

I added a wav file to my Windows Mobile app and I want to use MobilePlaySound in CoreDll.dll to play it. The fileName is one of its parameters: MobilePlaySound(fileName, IntPtr.Zero, (int)(Flags.SND_ASYNC | Flags.SND_FILENAME)); I create a new folder 'sound', add 'start.wav' to the project and set its property 'Build Action' to 'Emb...

How to get the path of app(without app.exe)?

I want to get the path of my app like: "\\ProgramFiles\\myApp", I try to use the following code: string path = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase; But it returns a path which has "\\myapp.exe" at the end. I also tried: string path = System.IO.Directory.GetCurrentDirectory(); But it throws an “No...

how to evaluate a given path within a bash shell

Hi all, Is there a bash command that takes as input a file path and returns an absolute file path? More specifically I would like a command that takes as input a path such as: /tmp/yaneeve/kit/linux/../../output/kit/SOURCES//usr//apps/myapp/lib and returns the path: /tmp/yaneeve/output/kit/SOURCES/usr/apps/myapp/lib Thanks! ...

wxWidgets: obtaining application path

How one can obtain path to module? I am writing extension enclosed in a DLL and want to get path to my library in runtime. Update Of course first way worked fine static wxString GetModulePath() { static wxString path; WCHAR buf[512] = {0}; GetModuleFileName(NULL, buf, 511); path = buf; return wxPathOnly(path); }...

UTF8 Filenames in PHP and Different Unicode Encodings

I have a file containing Unicode characters on a server running linux. If I SSH into the server and use tab-completion to navigate to the file/folder containing unicode characters I have no problem accessing the file/folder. The problem arises when I try accessing the file via PHP (the function I was accessing the file system from was st...

Java : File.toURI().toURL() on Windows file

The system I'm running on is Windows XP, with JRE 1.6. I do this : public static void main(String[] args) { try { System.out.println(new File("C:\\test a.xml").toURI().toURL()); } catch (Exception e) { e.printStackTrace(); } } and I get that : file:/C:/test%20a.xml How comes that the given URL has no...

Parsing XML files with Java and spaces in file path

I have files on my file system, on Windows XP. I want to parse them using Java (JRE 1.6). Problem is, I don't understand how Java and Xerces work together when the file path has spaces in it. If the file has no spaces in its path, all works fine. If there are spaces, I may have this kind of trouble, even if I call the parser with a Fi...

Getting the path to the directory of a given class file

I was confronted with code which tries to read some configuration files from the same directory where the .class file for the class itself is: File[] configFiles = new File( this.getClass().getResource(".").getPath()).listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.ends...

How can I make the relative paths to JS & SWF files in HTML work?

I have created a simple flash menu and the SWF file, JS files (swfoject.js and flying.js) & XML files are in a folder called "icpmenu_es" on the server root. If I open the SWF file on my local HDD it works fine but if I alter the paths to the files for use on my website, it won't work at all. I know it has found the JS files because if I...