You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

78 lines
3.1 KiB

  1. /* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. */
  21. using System.Diagnostics.CodeAnalysis;
  22. using System.Security;
  23. namespace Alphaleonis.Win32.Filesystem
  24. {
  25. public static partial class Path
  26. {
  27. #region GetRandomFileName (.NET)
  28. /// <summary>Returns a random folder name or file name.</summary>
  29. /// <returns>A random folder name or file name.</returns>
  30. [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
  31. [SecurityCritical]
  32. public static string GetRandomFileName()
  33. {
  34. return System.IO.Path.GetRandomFileName();
  35. }
  36. #endregion // GetRandomFileName (.NET)
  37. #region GetTempFileName (.NET)
  38. /// <summary>Creates a uniquely named, zero-byte temporary file on disk and returns the full path of that file.</summary>
  39. /// <returns>The full path of the temporary file.</returns>
  40. [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
  41. [SecurityCritical]
  42. public static string GetTempFileName()
  43. {
  44. return System.IO.Path.GetTempFileName();
  45. }
  46. #endregion // GetTempFileName (.NET)
  47. #region GetTempPath (.NET)
  48. /// <summary>Returns the path of the current user's temporary folder.</summary>
  49. /// <returns>The path to the temporary folder, ending with a backslash.</returns>
  50. [SecurityCritical]
  51. public static string GetTempPath()
  52. {
  53. return System.IO.Path.GetTempPath();
  54. }
  55. /// <summary>[AlphaFS] Returns the path of the current user's temporary folder.</summary>
  56. /// <param name="combinePath">The folder name to append to the temporary folder.</param>
  57. /// <returns>The path to the temporary folder, combined with <paramref name="combinePath"/>.</returns>
  58. [SecurityCritical]
  59. public static string GetTempPath(string combinePath)
  60. {
  61. string tempPath = GetTempPath();
  62. return !Utils.IsNullOrWhiteSpace(combinePath) ? CombineCore(false, tempPath, combinePath) : tempPath;
  63. }
  64. #endregion // GetTempPath (.NET)
  65. }
  66. }