Client/Server -- How to return a path string and have the client handle it properly?
My Server (WebService) is written in .NET on Windows Server 2008 + IIS Hosted. My Client can be any language on any machine type.
The problem: How do I return a "generic" filepath for the client to scan for?
I.E. I want to return (Folder)(Seperator)(FolderN)(Seperator)(Filename). I开发者_如何转开发t can be any number of folders deep and is a relative path from where the client installed the application.
Is it just up to the client to translate it if I return, for example, "MyFiles\SpecialFiles\SpecialFile1.txt" ? Or is it expected of me to pass back some special string character in place of the "\" that languages can know to translate into (Seperator)?
Just keep it simple. If you're running under windows, return the path like you described. IF you have a need to make it platform independent, and it can't be easily resolved in the client (which it should be), then tackle it then.
But there is no standard "directory separator" character.
I don't think this is what you're asking but you can use IO.Path.DirectorySeparatorChar. But that's not going to change based on your client.
精彩评论