当前位置: 首页>>代码示例>>C#>>正文


C# File.Mkdirs方法代码示例

本文整理汇总了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);
        }
开发者ID:pythe,项目名称:wristpass,代码行数:35,代码来源:TestCreateDb.cs

示例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();
        }
开发者ID:knezik,项目名称:gina-api-examples,代码行数:30,代码来源:DroidMapService.cs

示例3: CreateDirectoryForPictures

 private void CreateDirectoryForPictures()
 {
     _dir = new File(Environment.GetExternalStoragePublicDirectory(Environment.DirectoryPictures), "CameraAppDemo");
     if (_dir.Exists())
     {
         _dir.Mkdirs();
     }
 }
开发者ID:prashantvc,项目名称:monodroid-samples,代码行数:8,代码来源:MainActivity.cs

示例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;
        }
开发者ID:mehul19851,项目名称:xamarin-forms-camera,代码行数:22,代码来源:CameraProvider.cs

示例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;
 }
开发者ID:MahendrenGanesan,项目名称:samples,代码行数:19,代码来源:MainActivity.cs

示例6: CreatePhotoDir

 private void CreatePhotoDir()
 {
     try
     {
         _dir = new File(Environment.GetExternalStoragePublicDirectory(Environment.DirectoryPictures), _photoSubDir);
         if (!_dir.Exists())
             _dir.Mkdirs();
     }
     catch
     {
         _dir = null;
     }
 }
开发者ID:JC-Chris,项目名称:XFExtensions,代码行数:13,代码来源:MetaMediaActivity.cs

示例7: CreateDirectoryForPictures

		private void CreateDirectoryForPictures()
		{
		    mPollPictureDirectory = 
				new File(Android.OS.Environment.
				         GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), "MyVotePollImages");
		    if (!mPollPictureDirectory.Exists())
		    {
		        mPollPictureDirectory.Mkdirs();
		    }
		}
开发者ID:kamilkk,项目名称:MyVote,代码行数:10,代码来源:AddPollActivity.cs

示例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();
        }
开发者ID:jamisliao,项目名称:aws-sdk-net-samples,代码行数:10,代码来源:MainActivity.cs

示例9: CreateDirectoryForPictures

 private void CreateDirectoryForPictures()
 {
     _dir = new File(
         Environment.GetExternalStoragePublicDirectory(
             Environment.DirectoryPictures), "PrivatePhotos");
     if (!_dir.Exists())
     {
         _dir.Mkdirs();
     }
 }
开发者ID:Dneprik,项目名称:AndroidPrivatePhotoLibrary,代码行数:10,代码来源:MainActivity.cs

示例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);*/
        }
开发者ID:Teplitsa,项目名称:bezpregrad,代码行数:28,代码来源:Screen1Main.cs

示例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...");
        }
开发者ID:unhappy224,项目名称:NLog.IqMetrix,代码行数:37,代码来源:Activity1.cs

示例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;
        }
开发者ID:ryanerdmann,项目名称:angora,代码行数:21,代码来源:CustomCameraActivity.cs


注:本文中的File.Mkdirs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。