本文整理汇总了C#中File.mkdirs方法的典型用法代码示例。如果您正苦于以下问题:C# File.mkdirs方法的具体用法?C# File.mkdirs怎么用?C# File.mkdirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File.mkdirs方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteDOTFilesForAllDecisionDFAs
public void WriteDOTFilesForAllDecisionDFAs()
{
// for debugging, create a DOT file for each decision in
// a directory named for the grammar.
File grammarDir = new File( grammar.name + "_DFAs" );
grammarDir.mkdirs();
IList decisionList = grammar.getDecisionNFAStartStateList();
if ( decisionList == null )
{
return;
}
int i = 1;
Iterator iter = decisionList.iterator();
foreach ( NFAState decisionState in decisionList )
{
DFA dfa = decisionState.getDecisionASTNode().getLookaheadDFA();
if ( dfa != null )
{
String dot = getDOT( dfa.startState );
writeDOTFile( grammarDir + "/dec-" + i, dot );
}
i++;
}
}
示例2: save
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: void save(final android.media.Image image, String filename)
internal virtual void save(Image image, string filename)
{
File dir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).AbsolutePath + "/Camera/");
if (!dir.exists())
{
dir.mkdirs();
}
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.File file = new java.io.File(dir, filename);
File file = new File(dir, filename);
outerInstance.mBackgroundHandler.post(() =>
{
ByteBuffer buffer = image.Planes[0].Buffer;
sbyte[] bytes = new sbyte[buffer.remaining()];
buffer.get(bytes);
System.IO.FileStream output = null;
try
{
output = new System.IO.FileStream(file, System.IO.FileMode.Create, System.IO.FileAccess.Write);
output.Write(bytes, 0, bytes.Length);
}
catch (IOException e)
{
Console.WriteLine(e.ToString());
Console.Write(e.StackTrace);
}
finally
{
image.close();
if (null != output)
{
try
{
output.Close();
}
catch (IOException e)
{
Console.WriteLine(e.ToString());
Console.Write(e.StackTrace);
}
}
}
MediaScannerConnection.scanFile(outerInstance, new string[]{file.AbsolutePath}, null, new OnScanCompletedListenerAnonymousInnerClassHelper(this));
runOnUiThread(() =>
{
Toast.makeTextuniquetempvar.show();
});
});
}
示例3: extractAssets
/// <summary>
/// Extracts the media used by this sample to SD card or equivalent.
/// </summary>
private void extractAssets()
{
AssetManager assetManager = Assets;
File destDir = new File(Environment.ExternalStorageDirectory, ASSETS_SUBDIR);
if (!destDir.exists())
{
if (!destDir.mkdirs())
{
Toast.makeText(this, [email protected]_to_load_asset, Toast.LENGTH_LONG).show();
return;
}
}
foreach (string filename in ALL_ASSETS)
{
System.IO.Stream @in = null;
System.IO.Stream @out = null;
try
{
File destination = new File(destDir, filename);
if (destination.exists() == false)
{
@in = assetManager.open(filename);
@out = new System.IO.FileStream(destination, System.IO.FileMode.Create, System.IO.FileAccess.Write);
sbyte[] buffer = new sbyte[16 * 1024];
int read;
while ((read = @in.Read(buffer, 0, buffer.Length)) != -1)
{
@out.Write(buffer, 0, read);
}
}
}
catch (IOException)
{
Toast.makeText(this, [email protected]_to_load_asset, Toast.LENGTH_LONG).show();
// finish();
}
finally
{
if (@in != null)
{
try
{
@in.Close();
}
catch (IOException)
{
// Error during close, ignoring.
}
}
if (@out != null)
{
try
{
@out.Close();
}
catch (IOException)
{
// Error during close, ignoring.
}
}
}
}
}
示例4: save
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: void save(final android.media.Image image, String filename)
internal virtual void save(Image image, string filename)
{
File dir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).AbsolutePath + "/Camera/");
if (!dir.exists())
{
dir.mkdirs();
}
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.File file = new java.io.File(dir, filename);
File file = new File(dir, filename);
if (image.Format == ImageFormat.RAW_SENSOR)
{
SCaptureResult result = null;
try
{
result = outerInstance.mCaptureResultQueue.take();
}
catch (InterruptedException e)
{
Console.WriteLine(e.ToString());
Console.Write(e.StackTrace);
}
try
{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final com.samsung.android.sdk.camera.SDngCreator dngCreator = new com.samsung.android.sdk.camera.SDngCreator(mCharacteristics, result);
SDngCreator dngCreator = new SDngCreator(outerInstance.mCharacteristics, result);
dngCreator.Orientation = DNG_ORIENTATION.get(outerInstance.JpegOrientation);
(new Handler(Looper.myLooper())).post(() =>
{
ByteBuffer buffer = image.Planes[0].Buffer;
sbyte[] bytes = new sbyte[buffer.remaining()];
buffer.get(bytes);
System.IO.FileStream output = null;
try
{
output = new System.IO.FileStream(file, System.IO.FileMode.Create, System.IO.FileAccess.Write);
dngCreator.writeImage(output, image);
}
catch (IOException e)
{
Console.WriteLine(e.ToString());
Console.Write(e.StackTrace);
}
finally
{
image.close();
dngCreator.close();
if (null != output)
{
try
{
output.Close();
}
catch (IOException e)
{
Console.WriteLine(e.ToString());
Console.Write(e.StackTrace);
}
}
}
MediaScannerConnection.scanFile(outerInstance, new string[]{file.AbsolutePath}, null, new OnScanCompletedListenerAnonymousInnerClassHelper(this));
runOnUiThread(() =>
{
Toast.makeTextuniquetempvar.show();
});
});
}
catch (System.ArgumentException e)
{
Console.WriteLine(e.ToString());
Console.Write(e.StackTrace);
outerInstance.showAlertDialog("Fail to save DNG file.", false);
image.close();
return;
}
}
else
{
(new Handler(Looper.myLooper())).post(() =>
{
ByteBuffer buffer = image.Planes[0].Buffer;
sbyte[] bytes = new sbyte[buffer.remaining()];
buffer.get(bytes);
System.IO.FileStream output = null;
try
{
output = new System.IO.FileStream(file, System.IO.FileMode.Create, System.IO.FileAccess.Write);
output.Write(bytes, 0, bytes.Length);
}
catch (IOException e)
{
//.........这里部分代码省略.........
示例5: copyAssets
private void copyAssets()
{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String mSoundFontDir = android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DOWNLOADS).toString() + "/";
string mSoundFontDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).ToString() + "/";
string[] files = null;
string mkdir = null;
AssetManager assetManager = Assets;
try
{
files = assetManager.list("");
}
catch (IOException e)
{
Log.e(TAG, e.Message);
Console.WriteLine(e.ToString());
Console.Write(e.StackTrace);
return;
}
for (int i = 0; i < files.Length; i++)
{
System.IO.Stream @in = null;
System.IO.Stream @out = null;
try
{
File tmp = new File(mSoundFontDir, files[i]);
if (!tmp.exists())
{
@in = assetManager.open(files[i]);
}
if (@in == null)
{
continue;
}
mkdir = mSoundFontDir;
File mpath = new File(mkdir);
if (!mpath.Directory)
{
mpath.mkdirs();
}
@out = new System.IO.FileStream(mSoundFontDir + files[i], System.IO.FileMode.Create, System.IO.FileAccess.Write);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final byte[] buffer = new byte[1024];
sbyte[] buffer = new sbyte[1024];
int read;
while ((read = @in.Read(buffer, 0, buffer.Length)) != -1)
{
@out.Write(buffer, 0, read);
}
@in.Close();
@in = null;
@out.Flush();
@out.Close();
@out = null;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Console.Write(e.StackTrace);
}
}
}
示例6: Split
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void split(java.io.File destDir, String[] segs) throws java.io.IOException
public virtual void Split(File destDir, string[] segs)
{
destDir.mkdirs();
FSDirectory destFSDir = FSDirectory.open(destDir);
SegmentInfos destInfos = new SegmentInfos();
destInfos.counter = infos.counter;
foreach (string n in segs)
{
SegmentCommitInfo infoPerCommit = getInfo(n);
SegmentInfo info = infoPerCommit.info;
// Same info just changing the dir:
SegmentInfo newInfo = new SegmentInfo(destFSDir, info.Version, info.name, info.DocCount, info.UseCompoundFile, info.Codec, info.Diagnostics);
destInfos.add(new SegmentCommitInfo(newInfo, infoPerCommit.DelCount, infoPerCommit.DelGen, infoPerCommit.FieldInfosGen));
// now copy files over
ICollection<string> files = infoPerCommit.files();
foreach (String srcName in files)
{
File srcFile = new File(dir, srcName);
File destFile = new File(destDir, srcName);
copyFile(srcFile, destFile);
}
}
destInfos.changed();
destInfos.commit(destFSDir);
// System.out.println("destDir:"+destDir.getAbsolutePath());
}
示例7: onCreate
protected internal virtual void onCreate(Bundle savedInstanceState)
{
base.onCreate(savedInstanceState);
ContentView = R.layout.ft_sender_activity;
mCtxt = ApplicationContext;
mBtnSend = (Button) findViewById(R.id.Send);
mBtnSend.OnClickListener = this;
mBtnConn = (Button) findViewById(R.id.connectButton);
mBtnConn.OnClickListener = this;
mBtnCancel = (Button) findViewById(R.id.cancel);
mBtnCancel.OnClickListener = this;
mBtnCancelAll = (Button) findViewById(R.id.cancelAll);
mBtnCancelAll.OnClickListener = this;
if (!Environment.ExternalStorageState.Equals(Environment.MEDIA_MOUNTED))
{
Toast.makeText(mCtxt, " No SDCARD Present", Toast.LENGTH_SHORT).show();
finish();
}
else
{
mDirPath = Environment.ExternalStorageDirectory + File.separator + "FileTransferSender";
File file = new File(mDirPath);
if (file.mkdirs())
{
Toast.makeTextuniquetempvar.show();
}
}
mCtxt.bindService(new Intent(ApplicationContext, typeof(FileTransferSender)), this.mServiceConnection, Context.BIND_AUTO_CREATE);
mSentProgressBar = (ProgressBar) findViewById(R.id.fileTransferProgressBar);
mSentProgressBar.Max = 100;
}
示例8: onCreate
protected internal virtual void onCreate(Bundle savedInstanceState)
{
base.onCreate(savedInstanceState);
ContentView = R.layout.ft_receiver_activity;
mIsUp = true;
mCtxt = ApplicationContext;
mRecvProgressBar = (ProgressBar) findViewById(R.id.RecvProgress);
mRecvProgressBar.Max = 100;
if (!Environment.ExternalStorageState.Equals(Environment.MEDIA_MOUNTED))
{
Toast.makeText(mCtxt, " No SDCARD Present", Toast.LENGTH_SHORT).show();
finish();
}
else
{
mDirPath = Environment.ExternalStorageDirectory + File.separator + "FileTransferReceiver";
File file = new File(mDirPath);
if (file.mkdirs())
{
Toast.makeTextuniquetempvar.show();
}
}
mCtxt.bindService(new Intent(ApplicationContext, typeof(FileTransferReceiver)), this.mServiceConnection, Context.BIND_AUTO_CREATE);
}
示例9: downloadBigPicture
/// <summary>
/// Schedule the download of the big picture associated with the content. </summary>
/// <param name="context"> any application context. </param>
/// <param name="content"> content with big picture notification. </param>
public static void downloadBigPicture(Context context, EngagementReachInteractiveContent content)
{
/* Set up download request */
DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
Uri uri = Uri.parse(content.NotificationBigPicture);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.NotificationVisibility = DownloadManager.Request.VISIBILITY_HIDDEN;
request.VisibleInDownloadsUi = false;
/* Create intermediate directories */
File dir = context.getExternalFilesDir("engagement");
dir = new File(dir, "big-picture");
dir.mkdirs();
/* Set destination */
long contentId = content.LocalId;
request.DestinationUri = Uri.fromFile(new File(dir, contentId.ToString()));
/* Submit download */
long id = downloadManager.enqueue(request);
content.setDownloadId(context, id);
/* Set up timeout on download */
Intent intent = new Intent(EngagementReachAgent.INTENT_ACTION_DOWNLOAD_TIMEOUT);
intent.putExtra(EngagementReachAgent.INTENT_EXTRA_CONTENT_ID, contentId);
intent.Package = context.PackageName;
PendingIntent operation = PendingIntent.getBroadcast(context, (int) contentId, intent, 0);
long triggerAtMillis = SystemClock.elapsedRealtime() + DOWNLOAD_TIMEOUT;
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager.set(ELAPSED_REALTIME_WAKEUP, triggerAtMillis, operation);
}
示例10: selectImage
/// <summary>
/// select an image file for processing filter.
/// </summary>
private void selectImage()
{
mFileNames = null;
File cameraDirectory = new File(mCameraDirectory);
if (!cameraDirectory.exists())
{
cameraDirectory.mkdirs();
return;
}
File[] cameraImages = cameraDirectory.listFiles(new FileFilterAnonymousInnerClassHelper(this));
if (cameraImages == null || cameraImages.Length == 0)
{
return;
}
mFileNames = new string[cameraImages.Length];
for (int i = 0; i < cameraImages.Length; i++)
{
mFileNames[i] = mCameraDirectory + "/" + cameraImages[i].Name;
}
(new AlertDialog.Builder(Sample_Filter.this)).setTitle("Select Image").setItems(mFileNames, new OnClickListenerAnonymousInnerClassHelper(this))
.show();
}