/***********************************************************************************************************
Bits Download Manager
http://www.codeplex.com/BITSDownloadMgr
Component:BITSDownloadMgr.Jobs
File Name:FileUtilities.cs
Copyright (C) 2004-2007 Microsoft Corporation
This source is subject to the Microsoft Public License (Ms-PL).
See http:www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
All other rights reserved.
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
FITNESS FOR A PARTICULAR PURPOSE.
***********************************************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace BitsDownloadMgr.Jobs
{
static class FileUtilities
{
///
/// Checks a directory path and returns a normalized form with trailing \
///
///
///
public static string NormalizeDirectoryPath(string folderPath)
{
if (folderPath.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString(),
StringComparison.OrdinalIgnoreCase))
{
return folderPath;
}
else
{
return folderPath + System.IO.Path.DirectorySeparatorChar;
}
}
///
/// Returns a directory for a give path.
///
/// Path of the folder
/// Create the folder if it does not exist.
///
public static DirectoryInfo GetDirectoryInfo(string folderPath, bool createIfNotExists)
{
if (Directory.Exists(folderPath))
{
return new DirectoryInfo(folderPath);
}
else if (createIfNotExists)
{
return Directory.CreateDirectory(folderPath);
}
else
{
return null;
}
}
}
}