digitalmars.D.learn - Valid File Path
- vino (14/14) Aug 31 2017 Hi All,
- Cym13 (6/20) Aug 31 2017 It doesn't print anything because the path is valid. Why do you
- Vino (4/18) Aug 31 2017 Hi,
- Jonathan M Davis via Digitalmars-d-learn (11/34) Aug 31 2017 And why would that not be valid? isValidPath and isValidFilename are qui...
- Vino.B (5/20) Sep 01 2017 Hi,
Hi All, Can you help me what is wrong in the below program, as the output is empty. import std.stdio, std.path; void main () { version (Windows) { auto Path = `C:\#Users\Admin\Desktop\Script\Test1`; if(!Path.isValidPath) { writeln("Path Not Valid");} } } From, Vino.B
Aug 31 2017
On Thursday, 31 August 2017 at 21:59:22 UTC, vino wrote:Hi All, Can you help me what is wrong in the below program, as the output is empty. import std.stdio, std.path; void main () { version (Windows) { auto Path = `C:\#Users\Admin\Desktop\Script\Test1`; if(!Path.isValidPath) { writeln("Path Not Valid");} } } From, Vino.BIt doesn't print anything because the path is valid. Why do you expect otherwise? Note that isValidPath is only used for syntax check, it does not checks that the file or directory exists. If that is what you want use std.file.exists instead.
Aug 31 2017
On Thursday, 31 August 2017 at 21:59:22 UTC, vino wrote:Hi All, Can you help me what is wrong in the below program, as the output is empty. import std.stdio, std.path; void main () { version (Windows) { auto Path = `C:\#Users\Admin\Desktop\Script\Test1`; if(!Path.isValidPath) { writeln("Path Not Valid");} } } From, Vino.BHi, drive name.
Aug 31 2017
On Thursday, August 31, 2017 23:23:17 Vino via Digitalmars-d-learn wrote:On Thursday, 31 August 2017 at 21:59:22 UTC, vino wrote:And why would that not be valid? isValidPath and isValidFilename are quite a file name is perfectly legitimate. They do have some extra restrictions for Windows, since Windows is a lot pickier about its filenames than the https://dlang.org/phobos/std_path.html#isValidPath https://dlang.org/phobos/std_path.html#isValidFilename filename or directory name. - Jonathan M DavisHi All, Can you help me what is wrong in the below program, as the output is empty. import std.stdio, std.path; void main () { version (Windows) { auto Path = `C:\#Users\Admin\Desktop\Script\Test1`; if(!Path.isValidPath) { writeln("Path Not Valid");} } } From, Vino.BHi, drive name.
Aug 31 2017
On Thursday, 31 August 2017 at 23:45:01 UTC, Jonathan M Davis wrote:On Thursday, August 31, 2017 23:23:17 Vino via Digitalmars-d-learn wrote:Hi, Thank you very much for the explanation, was able to resolve the issue.[...]And why would that not be valid? isValidPath and isValidFilename are quite specific about what they think are perfectly legitimate. They do have some extra restrictions for Windows, since Windows is a lot pickier about its filenames listed as invalid: https://dlang.org/phobos/std_path.html#isValidPath https://dlang.org/phobos/std_path.html#isValidFilename perfectly legal in a filename or directory name. - Jonathan M Davis
Sep 01 2017