Like Tree2Likes
  • 1 Post By quzah
  • 1 Post By quzah

File path specifications

This is a discussion on File path specifications within the C# Programming forums, part of the General Programming Boards category; Ok hi all. I'm still working on that launcher/patcher, and I need a bit of heads up in a few ...

  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    62

    File path specifications

    Ok hi all.
    I'm still working on that launcher/patcher, and I need a bit of heads up in a few formatting things.

    So the question is: between web and local paths... Does using '/' or '\\' matter?

    Now a bit of explanation.

    In my resource file, I have a bunch of lines with this kind of formatting:
    Code:
    relative path to the file|version of the file
    the engine loads up both the server resource file and the one that is local to separate dictionaries.

    Then engine then compares the 2, deletes all local files that are not mentioned in the server, then downloads every file from the server that has a larger version.

    Notice that both paths are in this form:
    Code:
    string(prefix) + file_path_from_resource_tracker_file.
    so now I have to decide exactly how to save the path in the file.

    It can either be
    Code:
    "\\path\\to\\file"
    or
    Code:
    "/path/to/file"
    (maybe even
    Code:
    "\path\to\file"
    .

    So my question is which way would work for both a target computer relative path (absolute, prefixed with Directory.GetCurrentDirectory()) (C:\\ etc) AND an FTP server.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You can use @ to translate literal strings:
    Code:
    String path = @ "c:\windows\temp\";
    Assuming I have the string class right, I haven't actually used them much, and assuming that's what you are asking.

    That way you can enter the path as it would look in Explorer or whatever you are using to look at the path, and it will properly escape it for you.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Jul 2011
    Posts
    62
    thanks. so I just use \...
    That will work on an ftp server as well. Correct?

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Anything that would take a properly formatted string. Basically the @ does all the proper escaping for you. Read here: C# Station: C# Tutorial Lesson 02 - Operators, Types, and Variables


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Jul 2011
    Posts
    62
    Ah, seem to have missed that when looking for C# resources! Thanks for the link. (I've been missing the learncpp.com style tutorials XD)

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Here's another one: C# Key: C# 4.0 Programming

    Most of the links in the C# links thread are old and broken now.


    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    Registered User
    Join Date
    Mar 2009
    Location
    england
    Posts
    209
    If in doubt, use Path.Combine.

    Code:
    string path = Path.Combine("path", "to", "file");

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Exception specifications: throw() useful?
    By Memloop in forum C++ Programming
    Replies: 7
    Last Post: 11-25-2009, 02:24 AM
  2. XML Family of Specifications, by Kenneth B. Sall
    By neandrake in forum Programming Book and Product Reviews
    Replies: 0
    Last Post: 04-23-2009, 06:41 PM
  3. Getting file name off path
    By cgod in forum C++ Programming
    Replies: 6
    Last Post: 09-22-2005, 11:45 AM
  4. Obtaining System Specifications Through C++
    By SiLeNt BoB in forum C++ Programming
    Replies: 4
    Last Post: 06-06-2003, 09:40 AM
  5. Exception specifications: good or bad?
    By Just in forum C++ Programming
    Replies: 0
    Last Post: 02-19-2003, 09:19 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21