本文整理汇总了C#中File.Mkdirs方法的典型用法代码示例。如果您正苦于以下问题:C# File.Mkdirs方法的具体用法?C# File.Mkdirs怎么用?C# File.Mkdirs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File.Mkdirs方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAndSaveLocal
public void CreateAndSaveLocal()
{
IKp2aApp app = new TestKp2aApp();
IOConnectionInfo ioc = new IOConnectionInfo {Path = DefaultFilename};
File outputDir = new File(DefaultDirectory);
outputDir.Mkdirs();
File targetFile = new File(ioc.Path);
if (targetFile.Exists())
targetFile.Delete();
bool createSuccesful = false;
//create the task:
CreateDb createDb = new CreateDb(app, Application.Context, ioc, new ActionOnFinish((success, message) =>
{ createSuccesful = success;
if (!success)
Android.Util.Log.Debug("KP2A_Test", message);
}), false);
//run it:
createDb.Run();
//check expectations:
Assert.IsTrue(createSuccesful);
Assert.IsNotNull(app.GetDb());
Assert.IsNotNull(app.GetDb().KpDatabase);
//the create task should create two groups:
Assert.AreEqual(2, app.GetDb().KpDatabase.RootGroup.Groups.Count());
//ensure the the database can be loaded from file:
PwDatabase loadedDb = new PwDatabase();
loadedDb.Open(ioc, new CompositeKey(), null, new KdbxDatabaseFormat(KdbxFormat.Default));
//Check whether the databases are equal
AssertDatabasesAreEqual(loadedDb, app.GetDb().KpDatabase);
}
示例2: LoadNutiteqMap
public override bool LoadNutiteqMap(Nutiteq.Ui.MapView mapViewer)
{
_mapViewer = mapViewer;
// Register license
Nutiteq.Utils.Log.ShowError = true;
Nutiteq.Utils.Log.ShowWarn = true;
MapView.RegisterLicense("XTUMwQ0ZRQzdURnJKck9HYUdhT09VNGFSN3o3Nmg3UWhjQUlVTnV4TStMMk0vemhPMXUwUnBGRlhwbmFtTklFPQoKcHJvZHVjdHM9c2RrLXhhbWFyaW4taW9zLTMuKixzZGsteGFtYXJpbi1hbmRyb2lkLTMuKgpwYWNrYWdlTmFtZT1jb20ubnV0aXRlcS5oZWxsb21hcC54YW1hcmluCmJ1bmRsZUlkZW50aWZpZXI9Y29tLm51dGl0ZXEuaGVsbG9tYXAueGFtYXJpbgp3YXRlcm1hcms9bnV0aXRlcQp2YWxpZFVudGlsPTIwMTUtMDYtMDEKdXNlcktleT0yYTllOWY3NDYyY2VmNDgxYmUyYThjMTI2MWZlNmNiZAo", Application.Context);
// Create package manager folder (Platform-specific)
var packageFolder = new File(Application.Context.GetExternalFilesDir(null), "packages");
if (!(packageFolder.Mkdirs() || packageFolder.IsDirectory))
{
return false;
}
_downloadPackagePath = packageFolder.AbsolutePath;
// Copy bundled tile data to file system, so it can be imported by package manager
_importPackagePath = new File(Application.Context.GetExternalFilesDir(null), "world_ntvt_0_4.mbtiles").AbsolutePath;
using (var input = Application.Context.Assets.Open("world_ntvt_0_4.mbtiles"))
{
using (var output = new System.IO.FileStream(_importPackagePath, System.IO.FileMode.Create))
{
input.CopyTo(output);
}
}
// Initialize map
return LoadNutiteqMapCommon();
}
示例3: CreateDirectoryForPictures
private void CreateDirectoryForPictures()
{
_dir = new File(Environment.GetExternalStoragePublicDirectory(Environment.DirectoryPictures), "CameraAppDemo");
if (_dir.Exists())
{
_dir.Mkdirs();
}
}
示例4: TakePictureAsync
public Task<CameraResult> TakePictureAsync()
{
Intent intent = new Intent(MediaStore.ActionImageCapture);
pictureDirectory = new File(Environment.GetExternalStoragePublicDirectory(Environment.DirectoryPictures), "CameraAppDemo");
if (!pictureDirectory.Exists())
{
pictureDirectory.Mkdirs();
}
file = new File(pictureDirectory, String.Format("photo_{0}.jpg", Guid.NewGuid()));
intent.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(file));
var activity = (Activity)Forms.Context;
activity.StartActivityForResult(intent, 0);
tcs = new TaskCompletionSource<CameraResult>();
return tcs.Task;
}
示例5: GetOutputMediaFile
/// <summary>
/// Gets a file where to store the picture.
/// </summary>
private static File GetOutputMediaFile()
{
var mediaStorageDir = new File(Environment.GetExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "dot42 Simple Camera");
if (!mediaStorageDir.Exists())
{
if (!mediaStorageDir.Mkdirs())
{
Log.E("dot42 Simple Camera", "failed to create directory");
return null;
}
}
// Create a media file name
var timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").Format(new Date());
var mediaFile = new File(mediaStorageDir.Path + File.Separator + "IMG_" + timeStamp + ".jpg");
return mediaFile;
}
示例6: CreatePhotoDir
private void CreatePhotoDir()
{
try
{
_dir = new File(Environment.GetExternalStoragePublicDirectory(Environment.DirectoryPictures), _photoSubDir);
if (!_dir.Exists())
_dir.Mkdirs();
}
catch
{
_dir = null;
}
}
示例7: CreateDirectoryForPictures
private void CreateDirectoryForPictures()
{
mPollPictureDirectory =
new File(Android.OS.Environment.
GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), "MyVotePollImages");
if (!mPollPictureDirectory.Exists())
{
mPollPictureDirectory.Mkdirs();
}
}
示例8: InitializeClick
private async void InitializeClick(object sender, EventArgs e)
{
bool bucketExists = await S3Utils.BucketExist();
if (!bucketExists)
await S3Utils.CreateBucket();
appDirectory = new File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), "S3Droid");
if (!appDirectory.Exists())
appDirectory.Mkdirs();
}
示例9: CreateDirectoryForPictures
private void CreateDirectoryForPictures()
{
_dir = new File(
Environment.GetExternalStoragePublicDirectory(
Environment.DirectoryPictures), "PrivatePhotos");
if (!_dir.Exists())
{
_dir.Mkdirs();
}
}
示例10: photo_Touch
private void photo_Touch(object sender, View.TouchEventArgs e)
{
if (context.cameraBusy)
return;
context.cameraBusy = true;
_dir = new File(Environment.GetExternalStoragePublicDirectory(Environment.DirectoryPictures), "Pictures");
if (!_dir.Exists())
{
if (!_dir.Mkdirs())
throw new InvalidOperationException("Unable to create temporary directory");
}
var intent = new Intent(MediaStore.ActionImageCapture);
imageFile = new File(_dir, string.Format("image_{0}.jpg", Guid.NewGuid()));
intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(imageFile));
context.StartActivityForResult(intent, EditItemMainActivity.GetImageIntent);
/* var intent = new Intent();
intent.SetType("image/*");
intent.SetAction(Intent.ActionGetContent);
context.StartActivityForResult(Intent.CreateChooser(intent, "Выберите фото"), EditItemMainActivity.GetImageIntent);*/
}
示例11: InitializeNLog
private void InitializeNLog()
{
var sdCard = Environment.ExternalStorageDirectory;
var logDirectory = new File(sdCard.AbsolutePath + "/log");
logDirectory.Mkdirs();
var config = new LoggingConfiguration();
var csvFileTarget = new FileTarget
{
FileName = logDirectory.AbsolutePath + "/${shortdate}.csv"
,
Layout = new CsvLayout
{
Columns =
{
new CsvColumn("Time", "${longdate}"),
new CsvColumn("Level", "${level}"),
new CsvColumn("Lessage", "${message}"),
new CsvColumn("Logger", "${logger}")
},
}
};
var lumberMillTarget = new LumberMillTarget(_androidId);
config.AddTarget("CSV Logfile", csvFileTarget);
config.AddTarget("Lumbermill Log", lumberMillTarget);
var rule1 = new LoggingRule("*", LogLevel.Trace, csvFileTarget);
config.LoggingRules.Add(rule1);
var rule2 = new LoggingRule("*", LogLevel.Trace, lumberMillTarget);
config.LoggingRules.Add(rule2);
LogManager.Configuration = config;
_logger = LogManager.GetCurrentClassLogger();
_logger.Info("NLog successfully initialized.");
_logger.Debug("Application starting up...");
}
示例12: getOutputMediaFilepath
/** Generate a Filepath for saving the image */
private static string getOutputMediaFilepath()
{
File mediaStorageDir = new File(Environment.GetExternalStoragePublicDirectory(
Environment.DirectoryPictures), "SnapAndGo");
if (! mediaStorageDir.Exists()){
if (! mediaStorageDir.Mkdirs()){
Log.Error("SnapAndGo", "failed to create directory");
return null;
}
}
// Create a media file name
DateTime now = DateTime.Now;
String timeStamp = now.ToString("yyyyMMddHHmmss");
string pictureFilePath = mediaStorageDir.Path + File.Separator + "IMG_" + timeStamp + ".jpg";
return pictureFilePath;
}