1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107
|
<?xml version="1.0" encoding="utf-8"?>
<Type Name="Path" FullName="System.IO.Path" FullNameSP="System_IO_Path" Maintainer="ecma">
<TypeSignature Language="ILASM" Value=".class public sealed Path extends System.Object" />
<TypeSignature Language="C#" Value="public static class Path" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract sealed Path extends System.Object" />
<MemberOfLibrary>BCL</MemberOfLibrary>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyPublicKey>[00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ]</AssemblyPublicKey>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ThreadingSafetyStatement>All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.</ThreadingSafetyStatement>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute>
<AttributeName>System.Runtime.InteropServices.ComVisible(true)</AttributeName>
</Attribute>
</Attributes>
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The .NET Framework does not support direct access to physical disks through paths that are device names, such as "\\.\PHYSICALDRIVE0 ".</para>
<para>A path is a string that provides the location of a file or directory. A path does not necessarily point to a location on disk; for example, a path might map to a location in memory or on a device. The exact format of a path is determined by the current platform. For example, on some systems, a path can start with a drive or volume letter, while this element is not present in other systems. On some systems, file paths can contain extensions, which indicate the type of information stored in the file. The format of a file name extension is platform-dependent; for example, some systems limit extensions to three characters, and others do not. The current platform also determines the set of characters used to separate the elements of a path, and the set of characters that cannot be used when specifying paths. Because of these differences, the fields of the Path class as well as the exact behavior of some members of the Path class are platform-dependent.</para>
<para>A path can contain absolute or relative location information. Absolute paths fully specify a location: the file or directory can be uniquely identified regardless of the current location. Relative paths specify a partial location: the current location is used as the starting point when locating a file specified with a relative path. To determine the current directory, call <see cref="M:System.IO.Directory.GetCurrentDirectory" />.</para>
<para>Most members of the Path class do not interact with the file system and do not verify the existence of the file specified by a path string. Path class members that modify a path string, such as <see cref="M:System.IO.Path.ChangeExtension(System.String,System.String)" />, have no effect on names of files in the file system. Path members do, however, validate the contents of a specified path string, and throw an <see cref="T:System.ArgumentException" /> exception if the string contains characters that are not valid in path strings, as defined in the characters returned from the <see cref="M:System.IO.Path.GetInvalidPathChars" /> method. For example, on Windows-based desktop platforms, invalid path characters might include quote ("), less than (<), greater than (>), pipe (|), backspace (\b), null (\0), and Unicode characters 16 through 18 and 20 through 25.</para>
<para>The members of the Path class enable you to quickly and easily perform common operations such as determining whether a file name extension is part of a path, and combining two strings into one path name.</para>
<para>All members of the Path class are static and can therefore be called without having an instance of a path.</para>
<block subset="none" type="note">
<para>In members that accept a path as an input string, that path must be well-formed or an exception is raised. For example, if a path is fully qualified but begins with a space, the path is not trimmed in methods of the class. Therefore, the path is malformed and an exception is raised. Similarly, a path or a combination of paths cannot be fully qualified twice. For example, "c:\temp c:\windows" also raises an exception in most cases. Ensure that your paths are well-formed when using methods that accept a path string.</para>
</block>
<para>In members that accept a path, the path can refer to a file or just a directory. The specified path can also refer to a relative path or a Universal Naming Convention (UNC) path for a server and share name. For example, all the following are acceptable paths: </para>
<list type="bullet">
<item>
<para>"c:\\MyDir\\MyFile.txt" in C#, or "c:\MyDir\MyFile.txt" in Visual Basic.</para>
</item>
<item>
<para>"c:\\MyDir" in C#, or "c:\MyDir" in Visual Basic.</para>
</item>
<item>
<para>"MyDir\\MySubdir" in C#, or "MyDir\MySubDir" in Visual Basic.</para>
</item>
<item>
<para>"\\\\MyServer\\MyShare" in C#, or "\\MyServer\MyShare" in Visual Basic.</para>
</item>
</list>
<para>Because all these operations are performed on strings, it is impossible to verify that the results are valid in all scenarios. For example, the <see cref="M:System.IO.Path.GetExtension(System.String)" /> method parses a string that you pass to it and returns the extension from that string. However, this does not mean that a file with that extension exists on the disk.</para>
<para>For a list of common I/O tasks, see <format type="text/html"><a href="bf00c380-706a-4e38-b829-454a480629fc">Common I/O Tasks</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Performs operations on <see cref="T:System.String" /> instances that contain file or directory path information. These operations are performed in a cross-platform manner.</para>
</summary>
</Docs>
<Members>
<Member MemberName="AltDirectorySeparatorChar">
<MemberSignature Language="ILASM" Value=".field public static initOnly valuetype System.Char AltDirectorySeparatorChar" />
<MemberSignature Language="C#" Value="public static readonly char AltDirectorySeparatorChar;" />
<MemberSignature Language="ILAsm" Value=".field public static initonly char AltDirectorySeparatorChar" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Char</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The character stored in this field cannot be in <see cref="F:System.IO.Path.InvalidPathChars" />. This field can be set to the same value as <see cref="F:System.IO.Path.DirectorySeparatorChar" />. AltDirectorySeparatorChar and DirectorySeparatorChar are both valid for separating directory levels in a path string.</para>
<para>The value of this field is a backslash ('\') on UNIX, and a slash ('/') on Windows and Macintosh operating systems.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Provides a platform-specific alternate character used to separate directory levels in a path string that reflects a hierarchical file system organization.</para>
</summary>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="ChangeExtension">
<MemberSignature Language="ILASM" Value=".method public hidebysig static string ChangeExtension(string path, string extension)" />
<MemberSignature Language="C#" Value="public static string ChangeExtension (string path, string extension);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig string ChangeExtension(string path, string extension) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" />
<Parameter Name="extension" Type="System.String" />
</Parameters>
<Docs>
<exception cref="T:System.ArgumentException">
<paramref name="path" /> contains one or more implementation-specific invalid characters.</exception>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>If neither <paramref name="path" /> nor <paramref name="extension" /> contains a period (.), ChangeExtension adds the period.</para>
<para>The <paramref name="extension" /> parameter can contain multiple periods and any valid path characters, and can be any length. If <paramref name="extension" /> is null, the returned string contains the contents of <paramref name="path" /> with the last period and all characters following it removed.</para>
<para>If <paramref name="extension" /> is an empty string, the returned path string contains the contents of <paramref name="path" /> with any characters following the last period removed.</para>
<para>If <paramref name="path" /> does not have an extension and <paramref name="extension" /> is not null, the returned string contains <paramref name="path" /> followed by <paramref name="extension" />.</para>
<para>If <paramref name="extension" /> is not null and does not contain a leading period, the period is added.</para>
<para>If <paramref name="path" /> contains a multiple extension separated by multiple periods, the returned string contains the contents of <paramref name="path" /> with the last period and all characters following it replaced by <paramref name="extension" />. For example, if <paramref name="path" /> is "\Dir1\examples\pathtests.csx.txt" and <paramref name="extension" /> is "cs", the modified path is "\Dir1\examples\pathtests.csx.cs".</para>
<para>It is not possible to verify that the returned results are valid in all scenarios. For example, if <paramref name="path" /> is empty, <paramref name="extension" /> is appended.</para>
<para>For a list of common I/O tasks, see <format type="text/html"><a href="bf00c380-706a-4e38-b829-454a480629fc">Common I/O Tasks</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Changes the extension of a path string.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The modified path information.</para>
<para>On Windows-based desktop platforms, if <paramref name="path" /> is null or an empty string (""), the path information is returned unmodified. If <paramref name="extension" /> is null, the returned string contains the specified path with its extension removed. If <paramref name="path" /> has no extension, and <paramref name="extension" /> is not null, the returned path string contains <paramref name="extension" /> appended to the end of <paramref name="path" />.</para>
</returns>
<param name="path">
<attribution license="cc4" from="Microsoft" modified="false" />The path information to modify. The path cannot contain any of the characters defined in <see cref="M:System.IO.Path.GetInvalidPathChars" />. </param>
<param name="extension">
<attribution license="cc4" from="Microsoft" modified="false" />The new extension (with or without a leading period). Specify null to remove an existing extension from <paramref name="path" />. </param>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="Combine">
<MemberSignature Language="C#" Value="public static string Combine (string[] paths);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig string Combine(string[] paths) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="paths" Type="System.String[]">
<Attributes>
<Attribute>
<AttributeName>System.ParamArray</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>
<paramref name="paths " />should be an array of the parts of the path to combine. If the one of the subsequent paths is an absolute path, then the combine operation resets starting with that absolute path, discarding all previous combined paths.</para>
<para>Zero-length strings are omitted from the combined path.</para>
<para>The parameters are not parsed if they have white space. </para>
<para>Not all invalid characters for directory and file names are interpreted as unacceptable by the Combine method, because you can use these characters for search wildcard characters. For example, while Path.Combine("c:\\", "*.txt") might be invalid if you were to create a file from it, it is valid as a search string. It is therefore successfully interpreted by the Combine method.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Combines an array of strings into a path.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The combined paths.</para>
</returns>
<param name="paths">
<attribution license="cc4" from="Microsoft" modified="false" />An array of parts of the path.</param>
</Docs>
</Member>
<Member MemberName="Combine">
<MemberSignature Language="ILASM" Value=".method public hidebysig static string Combine(string path1, string path2)" />
<MemberSignature Language="C#" Value="public static string Combine (string path1, string path2);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig string Combine(string path1, string path2) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path1" Type="System.String" />
<Parameter Name="path2" Type="System.String" />
</Parameters>
<Docs>
<exception cref="T:System.ArgumentNullException">
<paramref name="path1" /> or <paramref name="path2" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">
<para>
<paramref name="path1" /> or <paramref name="path2" /> contains one or more implementation-specific invalid characters.</para>
</exception>
<example>
<para> The following example demonstrates using the
<see langword="Combine" /> method on a Windows system.</para>
<code lang="C#">using System;
using System.IO;
class CombineTest {
public static void Main() {
string path1, path2;
Console.WriteLine("Dir char is {0} Alt dir char is {1}",
Path.DirectorySeparatorChar,
Path.AltDirectorySeparatorChar
);
path1 = "foo.txt";
path2 = "\\ecmatest\\examples";
Console.WriteLine("{0} combined with {1} = {2}",path1, path2 , Path.Combine(path1,
path2));
path1 = "\\ecmatest\\examples";
path2 = "foo.txt";
Console.WriteLine("{0} combined with {1} = {2}",path1, path2 , Path.Combine(path1,
path2));
}
}
</code>
<para>The output is</para>
<c>
<para>Dir char is \ Alt dir char is /</para>
<para>foo.txt combined with \ecmatest\examples = \ecmatest\examples</para>
<para>\ecmatest\examples combined with foo.txt =
\ecmatest\examples\foo.txt</para>
</c>
</example>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>If <paramref name="path1" /> is not a drive reference (that is, "C:" or "D:") and does not end with a valid separator character as defined in <see cref="F:System.IO.Path.DirectorySeparatorChar" />, <see cref="F:System.IO.Path.AltDirectorySeparatorChar" />, or <see cref="F:System.IO.Path.VolumeSeparatorChar" />, <see cref="F:System.IO.Path.DirectorySeparatorChar" /> is appended to <paramref name="path1" /> before concatenation. </para>
<para>If <paramref name="path2" /> does not include a root (for example, if <paramref name="path2" /> does not start with a separator character or a drive specification), the result is a concatenation of the two paths, with an intervening separator character. If <paramref name="path2" /> includes a root, <paramref name="path2" /> is returned.</para>
<para>The parameters are not parsed if they have white space. Therefore, if <paramref name="path2" /> includes white space (for example, " c:\\ "), the <see cref="M:System.IO.Path.Combine(System.String,System.String)" /> method appends <paramref name="path2" /> to <paramref name="path1" /> instead of returning only <paramref name="path2" />.</para>
<para>Not all invalid characters for directory and file names are interpreted as unacceptable by the Combine method, because you can use these characters for search wildcard characters. For example, while Path.Combine("c:\\", "*.txt") might be invalid if you were to create a file from it, it is valid as a search string. It is therefore successfully interpreted by the Combine method.</para>
<para>For a list of common I/O tasks, see <format type="text/html"><a href="bf00c380-706a-4e38-b829-454a480629fc">Common I/O Tasks</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Combines two strings into a path.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The combined paths. If one of the specified paths is a zero-length string, this method returns the other path. If <paramref name="path2" /> contains an absolute path, this method returns <paramref name="path2" />.</para>
</returns>
<param name="path1">
<attribution license="cc4" from="Microsoft" modified="false" />The first path to combine. </param>
<param name="path2">
<attribution license="cc4" from="Microsoft" modified="false" />The second path to combine. </param>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="Combine">
<MemberSignature Language="C#" Value="public static string Combine (string path1, string path2, string path3);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig string Combine(string path1, string path2, string path3) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path1" Type="System.String" />
<Parameter Name="path2" Type="System.String" />
<Parameter Name="path3" Type="System.String" />
</Parameters>
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>
<paramref name="path1" /> should be an absolute path (for example, "d:\archives" or "\\archives\public"). If <paramref name="path2" /> or <paramref name="path3" /> is also an absolute path, the combine operation discards all previously combined paths and resets to that absolute path.</para>
<para>Zero-length strings are omitted from the combined path. </para>
<para>If <paramref name="path1" /> is not a drive reference (that is, "C:" or "D:") and does not end with a valid separator character as defined in <see cref="F:System.IO.Path.DirectorySeparatorChar" />, <see cref="F:System.IO.Path.AltDirectorySeparatorChar" />, or <see cref="F:System.IO.Path.VolumeSeparatorChar" />, <see cref="F:System.IO.Path.DirectorySeparatorChar" /> is appended to <paramref name="path1" /> before concatenation. </para>
<para>If <paramref name="path2" /> does not include a root (for example, if <paramref name="path2" /> does not start with a separator character or a drive specification), the result is a concatenation of the two paths, with an intervening separator character. If <paramref name="path2" /> includes a root, <paramref name="path2" /> is returned.</para>
<para>The parameters are not parsed if they have white space. Therefore, if <paramref name="path2" /> includes white space (for example, " c:\\ "), the <see cref="M:System.IO.Path.Combine(System.String,System.String)" /> method appends <paramref name="path2" /> to <paramref name="path1" /> instead of returning only <paramref name="path2" />.</para>
<para>Not all invalid characters for directory and file names are interpreted as unacceptable by the Combine method, because you can use these characters for search wildcard characters. For example, while Path.Combine("c:\\", "*.txt") might be invalid if you were to create a file from it, it is valid as a search string. It is therefore successfully interpreted by the Combine method.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Combines three strings into a path.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The combined paths.</para>
</returns>
<param name="path1">
<attribution license="cc4" from="Microsoft" modified="false" />The first path to combine. </param>
<param name="path2">
<attribution license="cc4" from="Microsoft" modified="false" />The second path to combine. </param>
<param name="path3">
<attribution license="cc4" from="Microsoft" modified="false" />The third path to combine.</param>
</Docs>
</Member>
<Member MemberName="Combine">
<MemberSignature Language="C#" Value="public static string Combine (string path1, string path2, string path3, string path4);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig string Combine(string path1, string path2, string path3, string path4) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path1" Type="System.String" />
<Parameter Name="path2" Type="System.String" />
<Parameter Name="path3" Type="System.String" />
<Parameter Name="path4" Type="System.String" />
</Parameters>
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>
<paramref name="path1" /> should be an absolute path (for example, "d:\archives" or "\\archives\public"). If one of the subsequent paths is also an absolute path, the combine operation discards all previously combined paths and resets to that absolute path.</para>
<para>Zero-length strings are omitted from the combined path.</para>
<para>If <paramref name="path1" /> is not a drive reference (that is, "C:" or "D:") and does not end with a valid separator character as defined in <see cref="F:System.IO.Path.DirectorySeparatorChar" />, <see cref="F:System.IO.Path.AltDirectorySeparatorChar" />, or <see cref="F:System.IO.Path.VolumeSeparatorChar" />, <see cref="F:System.IO.Path.DirectorySeparatorChar" /> is appended to <paramref name="path1" /> before concatenation. </para>
<para>If <paramref name="path2" /> does not include a root (for example, if <paramref name="path2" /> does not start with a separator character or a drive specification), the result is a concatenation of the two paths, with an intervening separator character. If <paramref name="path2" /> includes a root, <paramref name="path2" /> is returned.</para>
<para>The parameters are not parsed if they have white space. Therefore, if <paramref name="path2" /> includes white space (for example, " c:\\ "), the <see cref="M:System.IO.Path.Combine(System.String,System.String)" /> method appends <paramref name="path2" /> to <paramref name="path1" /> instead of returning only <paramref name="path2" />.</para>
<para>Not all invalid characters for directory and file names are interpreted as unacceptable by the Combine method, because you can use these characters for search wildcard characters. For example, while Path.Combine("c:\\", "*.txt") might be invalid if you were to create a file from it, it is valid as a search string. It is therefore successfully interpreted by the Combine method.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Combines four strings into a path.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The combined paths.</para>
</returns>
<param name="path1">
<attribution license="cc4" from="Microsoft" modified="false" />The first path to combine. </param>
<param name="path2">
<attribution license="cc4" from="Microsoft" modified="false" />The second path to combine. </param>
<param name="path3">
<attribution license="cc4" from="Microsoft" modified="false" />The third path to combine.</param>
<param name="path4">
<attribution license="cc4" from="Microsoft" modified="false" />The fourth path to combine.</param>
</Docs>
</Member>
<Member MemberName="DirectorySeparatorChar">
<MemberSignature Language="ILASM" Value=".field public static initOnly valuetype System.Char DirectorySeparatorChar" />
<MemberSignature Language="C#" Value="public static readonly char DirectorySeparatorChar;" />
<MemberSignature Language="ILAsm" Value=".field public static initonly char DirectorySeparatorChar" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Char</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The character stored in this field cannot be in <see cref="F:System.IO.Path.InvalidPathChars" />. <see cref="F:System.IO.Path.AltDirectorySeparatorChar" /> and DirectorySeparatorChar are both valid for separating directory levels in a path string.</para>
<para>The value of this field is a slash ("/") on UNIX, and a backslash ("\") on the Windows and Macintosh operating systems.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Provides a platform-specific character used to separate directory levels in a path string that reflects a hierarchical file system organization.</para>
</summary>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="GetDirectoryName">
<MemberSignature Language="ILASM" Value=".method public hidebysig static string GetDirectoryName(string path)" />
<MemberSignature Language="C#" Value="public static string GetDirectoryName (string path);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig string GetDirectoryName(string path) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" />
</Parameters>
<Docs>
<exception cref="T:System.ArgumentException">
<para>
<paramref name="path" /> contains one or more implementation-specific invalid characters.</para>
</exception>
<example>
<para>The following example demonstrates using the <see cref="M:System.IO.Path.GetDirectoryName(System.String)" /> method on a Windows system.</para>
<code lang="C#">using System;
using System.IO;
class GetDirectoryTest {
public static void Main() {
string [] paths = {
@"\ecmatest\examples\pathtests.txt",
@"\ecmatest\examples\",
"pathtests.xyzzy",
@"\",
@"C:\",
@"\\myserver\myshare\foo\bar\baz.txt"
};
foreach (string pathString in paths) {
string s = Path.GetDirectoryName(pathString);
Console.WriteLine("Path: {0} directory is {1}",pathString, s== null? "null": s);
}
}
}
</code>
<para>The output is </para>
<c>
<para>Path: \ecmatest\examples\pathtests.txt directory is \ecmatest\examples</para>
<para>Path: \ecmatest\examples\ directory is \ecmatest\examples</para>
<para> Path: pathtests.xyzzy directory is</para>
<para> Path: \ directory is null</para>
<para>Path: C:\ directory is null</para>
<para>Path: \\myserver\myshare\foo\bar\baz.txt directory is \\myserver\myshare\foo\bar</para>
</c>
</example>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>In most cases, the string returned by this method consists of all characters in the path up to but not including the last <see cref="F:System.IO.Path.DirectorySeparatorChar" /> or <see cref="F:System.IO.Path.AltDirectorySeparatorChar" />. If the path consists of a root directory, such as "c:\", null is returned. Note that this method does not support paths using "file:". Because the returned path does not include the <see cref="F:System.IO.Path.DirectorySeparatorChar" /> or <see cref="F:System.IO.Path.AltDirectorySeparatorChar" />, passing the returned path back into the <see cref="M:System.IO.Path.GetDirectoryName(System.String)" /> method will result in the truncation of one folder level per subsequent call on the result string. For example, passing the path "C:\Directory\SubDirectory\test.txt" into the <see cref="M:System.IO.Path.GetDirectoryName(System.String)" /> method will return "C:\Directory\SubDirectory". Passing that string, "C:\Directory\SubDirectory", into <see cref="M:System.IO.Path.GetDirectoryName(System.String)" /> will result in "C:\Directory".</para>
<para>For a list of common I/O tasks, see <format type="text/html"><a href="bf00c380-706a-4e38-b829-454a480629fc">Common I/O Tasks</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Returns the directory information for the specified path string.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Directory information for <paramref name="path" />, or null if <paramref name="path" /> denotes a root directory or is null. Returns <see cref="F:System.String.Empty" /> if <paramref name="path" /> does not contain directory information.</para>
</returns>
<param name="path">
<attribution license="cc4" from="Microsoft" modified="false" />The path of a file or directory. </param>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="GetExtension">
<MemberSignature Language="ILASM" Value=".method public hidebysig static string GetExtension(string path)" />
<MemberSignature Language="C#" Value="public static string GetExtension (string path);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig string GetExtension(string path) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" />
</Parameters>
<Docs>
<exception cref="T:System.ArgumentException">
<para>
<paramref name="path" /> contains one or more implementation-specific invalid characters.</para>
</exception>
<example>
<para>The following example demonstrates using the <see cref="M:System.IO.Path.GetExtension(System.String)" /> method on a Windows
system.</para>
<code lang="C#">using System;
using System.IO;
class GetDirectoryTest {
public static void Main(){
string [] paths = {
@"\ecmatest\examples\pathtests.txt",
@"\ecmatest\examples\",
"pathtests.xyzzy",
"pathtests.xyzzy.txt",
@"\",
""
};
foreach (string pathString in paths){
string s = Path.GetExtension (pathString);
if (s == String.Empty) s= "(empty string)";
if (s == null) s= "null";
Console.WriteLine("{0} is the extension of {1}", s, pathString);
}
}
}
</code>
<para>The output is</para>
<c>
<para>.txt is the extension of \ecmatest\examples\pathtests.txt</para>
<para>(empty string) is the extension of \ecmatest\examples\ </para>
<para>.xyzzy is the extension of pathtests.xyzzy </para>
<para>.txt is the extension of pathtests.xyzzy.txt </para>
<para>(empty string) is the extension of \ </para>
<para>(empty string) is the extension of </para>
</c>
</example>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The extension of <paramref name="path" /> is obtained by searching <paramref name="path" /> for a period (.), starting with the last character in path and continuing toward the start of path. If a period is found before a <see cref="F:System.IO.Path.DirectorySeparatorChar" /> or <see cref="F:System.IO.Path.AltDirectorySeparatorChar" /> character, the returned string contains the period and the characters after it; otherwise, <see cref="F:System.String.Empty" /> is returned.</para>
<para>For a list of common I/O tasks, see <format type="text/html"><a href="bf00c380-706a-4e38-b829-454a480629fc">Common I/O Tasks</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Returns the extension of the specified path string.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The extension of the specified path (including the period "."), or null, or <see cref="F:System.String.Empty" />. If <paramref name="path" /> is null, <see cref="M:System.IO.Path.GetExtension(System.String)" /> returns null. If <paramref name="path" /> does not have extension information, <see cref="M:System.IO.Path.GetExtension(System.String)" /> returns <see cref="F:System.String.Empty" />.</para>
</returns>
<param name="path">
<attribution license="cc4" from="Microsoft" modified="false" />The path string from which to get the extension. </param>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="GetFileName">
<MemberSignature Language="ILASM" Value=".method public hidebysig static string GetFileName(string path)" />
<MemberSignature Language="C#" Value="public static string GetFileName (string path);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig string GetFileName(string path) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" />
</Parameters>
<Docs>
<exception cref="T:System.ArgumentException">
<paramref name="path" /> contains one or more implementation-specific invalid characters.</exception>
<example>
<para>The following example demonstrates the behavior of the
<see cref="M:System.IO.Path.GetFileName(System.String)" /> method on a
Windows system.</para>
<code lang="C#">using System;
using System.IO;
class FileNameTest {
public static void Main() {
string [] paths = {"pathtests.txt",
@"\ecmatest\examples\pathtests.txt",
"c:pathtests.txt",
@"\ecmatest\examples\",
""
};
foreach (string p in paths) {
Console.WriteLine("Path: {0} filename = {1}",p, Path.GetFileName(p));
}
}
}
</code>
<para>The output is </para>
<c>
<para>Path: pathtests.txt filename = pathtests.txt </para>
<para>Path: \ecmatest\examples\pathtests.txt filename = pathtests.txt </para>
<para>Path: c:pathtests.txt filename = pathtests.txt </para>
<para>Path: \ecmatest\examples\ filename = </para>
<para>Path: filename = </para>
</c>
</example>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The returned value is null if the file path is null.</para>
<para>The separator characters used to determine the start of the file name are <see cref="F:System.IO.Path.DirectorySeparatorChar" /> and <see cref="F:System.IO.Path.AltDirectorySeparatorChar" />.</para>
<para>For a list of common I/O tasks, see <format type="text/html"><a href="bf00c380-706a-4e38-b829-454a480629fc">Common I/O Tasks</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Returns the file name and extension of the specified path string.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The characters after the last directory character in <paramref name="path" />. If the last character of <paramref name="path" /> is a directory or volume separator character, this method returns <see cref="F:System.String.Empty" />. If <paramref name="path" /> is null, this method returns null.</para>
</returns>
<param name="path">
<attribution license="cc4" from="Microsoft" modified="false" />The path string from which to obtain the file name and extension. </param>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="GetFileNameWithoutExtension">
<MemberSignature Language="ILASM" Value=".method public hidebysig static string GetFileNameWithoutExtension(string path)" />
<MemberSignature Language="C#" Value="public static string GetFileNameWithoutExtension (string path);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig string GetFileNameWithoutExtension(string path) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" />
</Parameters>
<Docs>
<exception cref="T:System.ArgumentException">
<paramref name="path" /> contains one or more implementation-specific invalid characters.</exception>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>This method does not verify that the path or file name exists.</para>
<para>For a list of common I/O tasks, see <format type="text/html"><a href="bf00c380-706a-4e38-b829-454a480629fc">Common I/O Tasks</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Returns the file name of the specified path string without the extension.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The string returned by <see cref="M:System.IO.Path.GetFileName(System.String)" />, minus the last period (.) and all characters following it.</para>
</returns>
<param name="path">
<attribution license="cc4" from="Microsoft" modified="false" />The path of the file. </param>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="GetFullPath">
<MemberSignature Language="ILASM" Value=".method public hidebysig static string GetFullPath(string path)" />
<MemberSignature Language="C#" Value="public static string GetFullPath (string path);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig string GetFullPath(string path) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" />
</Parameters>
<Docs>
<exception cref="T:System.ArgumentException">
<para>
<paramref name="path " />is a zero-length string, contains only white space, or contains one or more implementation-specific invalid characters.</para>
<para>-or-</para>
<para>The system could not retrieve the absolute path.</para>
</exception>
<exception cref="T:System.Security.SecurityException">The caller does not have the required permissions.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="path" /> is <see langword="null" /> .</exception>
<exception cref="T:System.IO.PathTooLongException">The length of <paramref name="path" /> or the absolute path information for <paramref name="path" /> exceeds the system-defined maximum length.</exception>
<permission cref="T:System.Security.Permissions.FileIOPermission">Requires permission to access path information. See <see langword="System.Security.Permissions.FileIOPermissionAccess.PathDiscovery" /> .</permission>
<example>
<para> The following example demonstrates the <see cref="M:System.IO.Path.GetFullPath(System.String)" /> method on a Windows system. In
this example, the absolute path for the current directory is c:\ecmatest\examples.</para>
<code lang="C#">using System;
using System.IO;
class GetDirectoryTest {
public static void Main() {
string [] paths = {
@"\ecmatest\examples\pathtests.txt",
@"\ecmatest\examples\",
"pathtests.xyzzy",
@"\",
};
foreach (string pathString in paths)
Console.WriteLine("Path: {0} full path is {1}",pathString,
Path.GetFullPath(pathString));
}
}
</code>
<para>The output is </para>
<c>
<para>Path: \ecmatest\examples\pathtests.txt full path is
C:\ecmatest\examples\pathtests.txt</para>
<para>Path: \ecmatest\examples\ full path is C:\ecmatest\examples\</para>
<para>Path: pathtests.xyzzy full path is
C:\ecmatest\examples\pathtests.xyzzy</para>
<para>Path: \ full path is C:\ </para>
</c>
</example>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The .NET Framework does not support direct access to physical disks through paths that are device names, such as "\\.\PHYSICALDRIVE0 ".</para>
<para>The absolute path includes all information required to locate a file or directory on a system.</para>
<para>The file or directory specified by <paramref name="path" /> is not required to exist. For example, if c:\temp\newdir is the current directory, calling GetFullPath on a file name such as test.txt returns c:\temp\newdir\test.txt. The file need not exist.</para>
<para>However, if <paramref name="path" /> does exist, the caller must have permission to obtain path information for <paramref name="path" />. Note that unlike most members of the <see cref="T:System.IO.Path" /> class, this method accesses the file system.</para>
<para>This method uses current directory and current volume information to fully qualify <paramref name="path" />. If you specify a file name only in <paramref name="path" />, GetFullPath returns the fully qualified path of the current directory.</para>
<para>If you pass in a short file name, it is expanded to a long file name.</para>
<para>If a path contains no significant characters it is invalid unless it contains one or more "." characters followed by any number of spaces, then it will be parsed as either "." or "..".</para>
<para>For a list of common I/O tasks, see <format type="text/html"><a href="bf00c380-706a-4e38-b829-454a480629fc">Common I/O Tasks</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Returns the absolute path for the specified path string.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The fully qualified location of <paramref name="path" />, such as "C:\MyFile.txt".</para>
</returns>
<param name="path">
<attribution license="cc4" from="Microsoft" modified="false" />The file or directory for which to obtain absolute path information. </param>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="GetInvalidFileNameChars">
<MemberSignature Language="C#" Value="public static char[] GetInvalidFileNameChars ();" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig char[] GetInvalidFileNameChars() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Char[]</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<since version=".NET 2.0" />
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The array returned from this method is not guaranteed to contain the complete set of characters that are invalid in file and directory names. The full set of invalid characters can vary by file system. For example, on Windows-based desktop platforms, invalid path characters might include ASCII/Unicode characters 1 through 31, as well as quote ("), less than (<), greater than (>), pipe (|), backspace (\b), null (\0) and tab (\t).</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Gets an array containing the characters that are not allowed in file names.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>An array containing the characters that are not allowed in file names.</para>
</returns>
</Docs>
</Member>
<Member MemberName="GetInvalidPathChars">
<MemberSignature Language="C#" Value="public static char[] GetInvalidPathChars ();" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig char[] GetInvalidPathChars() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Char[]</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<since version=".NET 2.0" />
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The array returned from this method is not guaranteed to contain the complete set of characters that are invalid in file and directory names. The full set of invalid characters can vary by file system. For example, on Windows-based desktop platforms, invalid path characters might include ASCII/Unicode characters 1 through 31, as well as quote ("), less than (<), greater than (>), pipe (|), backspace (\b), null (\0) and tab (\t).</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Gets an array containing the characters that are not allowed in path names.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>An array containing the characters that are not allowed in path names.</para>
</returns>
</Docs>
</Member>
<Member MemberName="GetPathRoot">
<MemberSignature Language="ILASM" Value=".method public hidebysig static string GetPathRoot(string path)" />
<MemberSignature Language="C#" Value="public static string GetPathRoot (string path);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig string GetPathRoot(string path) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" />
</Parameters>
<Docs>
<exception cref="T:System.ArgumentException">
<paramref name="path" /> contains one or more implementation-specific invalid characters or is equal to <see cref="F:System.String.Empty" /> . </exception>
<example>
<para>The following example demonstrates the <see cref="M:System.IO.Path.GetPathRoot(System.String)" />
method.</para>
<code lang="C#">using System;
using System.IO;
class GetPathRootTest
{
public static void Main() {
string [] paths = {
@"\ecmatest\examples\pathtests.txt",
"pathtests.xyzzy",
@"\",
@"C:\",
@"\\myserver\myshare\foo\bar\baz.txt"
};
foreach (string pathString in paths) {
string s = Path.GetPathRoot(pathString);
Console.WriteLine("Path: {0} Path root is {1}",pathString, s== null? "null": s);
}
}
}
</code>
<para>The output is</para>
<c>
<para>Path: \ecmatest\examples\pathtests.txt Path root is \</para>
<para>Path: pathtests.xyzzy Path root is</para>
<para>Path: \ Path root is \</para>
<para>Path: C:\ Path root is C:\</para>
<para>Path: \\myserver\myshare\foo\bar\baz.txt
Path root is \\myserver\myshare</para>
</c>
</example>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>This method does not verify that the path or file name exists.</para>
<para>Possible patterns for the string returned by this method are as follows: </para>
<list type="bullet">
<item>
<para>An empty string (<paramref name="path" /> specified a relative path on the current drive or volume).</para>
</item>
<item>
<para>"/" (<paramref name="path" /> specified an absolute path on the current drive).</para>
</item>
<item>
<para>"X:" (<paramref name="path" /> specified a relative path on a drive, where X represents a drive or volume letter).</para>
</item>
<item>
<para>"X:/" (<paramref name="path" /> specified an absolute path on a given drive).</para>
</item>
<item>
<para>"\\ComputerName\SharedFolder" (a UNC path).</para>
</item>
</list>
<para>The .NET Framework does not support direct access to physical disks through paths that are device names, such as "\\.\PHYSICALDRIVE0 ".</para>
<para>For a list of common I/O tasks, see <format type="text/html"><a href="bf00c380-706a-4e38-b829-454a480629fc">Common I/O Tasks</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Gets the root directory information of the specified path.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The root directory of <paramref name="path" />, such as "C:\", or null if <paramref name="path" /> is null, or an empty string if <paramref name="path" /> does not contain root directory information.</para>
</returns>
<param name="path">
<attribution license="cc4" from="Microsoft" modified="false" />The path from which to obtain root directory information. </param>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="GetRandomFileName">
<MemberSignature Language="C#" Value="public static string GetRandomFileName ();" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig string GetRandomFileName() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<since version=".NET 2.0" />
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The <see cref="M:System.IO.Path.GetRandomFileName" /> method returns a cryptographically strong, random string that can be used as either a folder name or a file name. Unlike <see cref="M:System.IO.Path.GetTempFileName" />, <see cref="M:System.IO.Path.GetRandomFileName" /> does not create a file. When the security of your file system is paramount, this method should be used instead of <see cref="M:System.IO.Path.GetTempFileName" />.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Returns a random folder name or file name.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>A random folder name or file name.</para>
</returns>
</Docs>
</Member>
<Member MemberName="GetTempFileName">
<MemberSignature Language="ILASM" Value=".method public hidebysig static string GetTempFileName()" />
<MemberSignature Language="C#" Value="public static string GetTempFileName ();" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig string GetTempFileName() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>This method creates a temporary file with a .TMP file extension. The temporary file is created within the user’s temporary folder, which is the path returned by the <see cref="M:System.IO.Path.GetTempPath" /> method.</para>
<para>The <see cref="M:System.IO.Path.GetTempFileName" /> method will raise an <see cref="T:System.IO.IOException" /> if it is used to create more than 65535 files without deleting previous temporary files.</para>
<para>The <see cref="M:System.IO.Path.GetTempFileName" /> method will raise an <see cref="T:System.IO.IOException" /> if no unique temporary file name is available. To resolve this error, delete all unneeded temporary files.</para>
<para>For a list of common I/O tasks, see <format type="text/html"><a href="bf00c380-706a-4e38-b829-454a480629fc">Common I/O Tasks</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Creates a uniquely named, zero-byte temporary file on disk and returns the full path of that file.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The full path of the temporary file.</para>
</returns>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="GetTempPath">
<MemberSignature Language="ILASM" Value=".method public hidebysig static string GetTempPath()" />
<MemberSignature Language="C#" Value="public static string GetTempPath ();" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig string GetTempPath() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception>
<permission cref="T:System.Security.Permissions.EnvironmentPermission">Requires unrestricted access to environment variables. See <see cref="F:System.Security.Permissions.PermissionState.Unrestricted" />.</permission>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>This method checks for the existence of environment variables in the following order and uses the first path found:</para>
<list type="ordered">
<item>
<para>The path specified by the TMP environment variable.</para>
</item>
<item>
<para>The path specified by the TEMP environment variable.</para>
</item>
<item>
<para>The path specified by the USERPROFILE environment variable.</para>
</item>
<item>
<para>The Windows directory.</para>
</item>
</list>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Returns the path of the current user's temporary folder.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The path to the temporary folder, ending with a backslash.</para>
</returns>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="HasExtension">
<MemberSignature Language="ILASM" Value=".method public hidebysig static bool HasExtension(string path)" />
<MemberSignature Language="C#" Value="public static bool HasExtension (string path);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig bool HasExtension(string path) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" />
</Parameters>
<Docs>
<exception cref="T:System.ArgumentException">
<paramref name="path" /> contains one or more implementation-specific invalid characters. </exception>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Starting from the end of <paramref name="path" />, this method searches for a period (.) followed by at least one character. If this pattern is found before a <see cref="F:System.IO.Path.DirectorySeparatorChar" />, <see cref="F:System.IO.Path.AltDirectorySeparatorChar" />, or <see cref="F:System.IO.Path.VolumeSeparatorChar" /> character is encountered, this method returns true.</para>
<para>For a list of common I/O tasks, see <format type="text/html"><a href="bf00c380-706a-4e38-b829-454a480629fc">Common I/O Tasks</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Determines whether a path includes a file name extension.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>true if the characters that follow the last directory separator (\\ or /) or volume separator (:) in the path include a period (.) followed by one or more characters; otherwise, false.</para>
</returns>
<param name="path">
<attribution license="cc4" from="Microsoft" modified="false" />The path to search for an extension. </param>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="InvalidPathChars">
<MemberSignature Language="C#" Value="public static readonly char[] InvalidPathChars;" />
<MemberSignature Language="ILAsm" Value=".field public static initonly char[] InvalidPathChars" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName>System.Obsolete("see GetInvalidPathChars and GetInvalidFileNameChars methods.")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Char[]</ReturnType>
</ReturnValue>
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The array returned from this method is not guaranteed to contain the complete set of characters that are invalid in file and directory names. The full set of invalid characters can vary by file system. For example, on Windows-based desktop platforms, invalid path characters might include ASCII/Unicode characters 1 through 31, as well as quote ("), less than (<), greater than (>), pipe (|), backspace (\b), null (\0) and tab (\t).</para>
<block subset="none" type="note">
<para>Do not use <see cref="F:System.IO.Path.InvalidPathChars" /> if you think your code might execute in the same application domain as untrusted code. <see cref="F:System.IO.Path.InvalidPathChars" /> is an array, so its elements can be overwritten. If untrusted code overwrites elements of <see cref="F:System.IO.Path.InvalidPathChars" />, it might cause your code to malfunction in ways that could be exploited.</para>
</block>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Provides a platform-specific array of characters that cannot be specified in path string arguments passed to members of the <see cref="T:System.IO.Path" /> class.</para>
</summary>
</Docs>
</Member>
<Member MemberName="IsPathRooted">
<MemberSignature Language="ILASM" Value=".method public hidebysig static bool IsPathRooted(string path)" />
<MemberSignature Language="C#" Value="public static bool IsPathRooted (string path);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig bool IsPathRooted(string path) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="System.String" />
</Parameters>
<Docs>
<exception cref="T:System.ArgumentException">
<paramref name="path" /> contains one or more implementation-specific invalid characters.</exception>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The <see cref="M:System.IO.Path.IsPathRooted(System.String)" /> method returns true if the first character is a directory separator character such as "\", or if the path starts with a drive letter and colon (:). For example, it returns true for <paramref name="path" /> strings such as "\\MyDir\\MyFile.txt", "C:\\MyDir", or "C:MyDir". It returns false for <paramref name="path" /> strings such as "MyDir".</para>
<para>This method does not verify that the path or file name exists.</para>
<para>For a list of common I/O tasks, see <format type="text/html"><a href="bf00c380-706a-4e38-b829-454a480629fc">Common I/O Tasks</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Gets a value indicating whether the specified path string contains a root.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>true if <paramref name="path" /> contains a root; otherwise, false.</para>
</returns>
<param name="path">
<attribution license="cc4" from="Microsoft" modified="false" />The path to test. </param>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="PathSeparator">
<MemberSignature Language="ILASM" Value=".field public static initOnly valuetype System.Char PathSeparator" />
<MemberSignature Language="C#" Value="public static readonly char PathSeparator;" />
<MemberSignature Language="ILAsm" Value=".field public static initonly char PathSeparator" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Char</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>On Windows-based desktop platforms, the value of this field is the semicolon (;) by default, but might vary on other platforms.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>A platform-specific separator character used to separate path strings in environment variables.</para>
</summary>
</Docs>
<Excluded>0</Excluded>
</Member>
<Member MemberName="VolumeSeparatorChar">
<MemberSignature Language="C#" Value="public static readonly char VolumeSeparatorChar;" />
<MemberSignature Language="ILAsm" Value=".field public static initonly char VolumeSeparatorChar" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Char</ReturnType>
</ReturnValue>
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>The value of this field is a colon (:) on Windows and Macintosh, and a slash (/) on UNIX operating systems. This is most useful for parsing paths such as "c:\windows" or "MacVolume:System Folder".</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Provides a platform-specific volume separator character.</para>
</summary>
</Docs>
</Member>
</Members>
<TypeExcluded>0</TypeExcluded>
</Type>
|