本文整理汇总了C#中FileAction类的典型用法代码示例。如果您正苦于以下问题:C# FileAction类的具体用法?C# FileAction怎么用?C# FileAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileAction类属于命名空间,在下文中一共展示了FileAction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HandleAction
public void HandleAction(string input, FileAction action)
{
switch (action)
{
case FileAction.NewFolder:
{
Directory.CreateDirectory(comboDrive.Text + txtAddress.Text + input);
ProcessDirectories(new DirectoryInfo(comboDrive.Text + txtAddress.Text));
break;
}
case FileAction.NewFile:
{
File.Create(comboDrive.Text + txtAddress.Text + input);
ProcessDirectories(new DirectoryInfo(comboDrive.Text + txtAddress.Text));
break;
}
case FileAction.Delete:
{
if (input.ToLower() == listDir.SelectedItems[0].Text.ToLower())
{
if (Directory.Exists(comboDrive.Text + txtAddress.Text + listDir.SelectedItems[0].Text))
Directory.Delete(comboDrive.Text + txtAddress.Text + listDir.SelectedItems[0].Text);
else if (File.Exists(comboDrive.Text + txtAddress.Text + listDir.SelectedItems[0].Text))
File.Delete(comboDrive.Text + txtAddress.Text + listDir.SelectedItems[0].Text);
}
else
MessageBox.Show("Error: File/Directory does not exsist.");
ProcessDirectories(new DirectoryInfo(comboDrive.Text + txtAddress.Text));
break;
}
}
}
开发者ID:stratex,项目名称:Basic-File-Manager,代码行数:32,代码来源:MainView.cs
示例2: OnFileAction
/// <summary>
/// Gets called after a file action was perforem for example after a rename or copy.
/// </summary>
/// <param name="man">ManagerEngine reference that the plugin is assigned to.</param>
/// <param name="action">File action type.</param>
/// <param name="file1">File object 1 for example from in a copy operation.</param>
/// <param name="file2">File object 2 for example to in a copy operation. Might be null in for example a delete.</param>
/// <returns>true/false if the execution of the event chain should continue execution.</returns>
public override bool OnFileAction(ManagerEngine man, FileAction action, IFile file1, IFile file2)
{
if (action != FileAction.Add)
return true;
HttpResponse response = HttpContext.Current.Response;
HttpRequest request = HttpContext.Current.Request;
HttpCookie cookie;
ArrayList chunks;
if ((cookie = request.Cookies["upl"]) == null)
cookie = new HttpCookie("upl");
cookie.Expires = DateTime.Now.AddDays(30);
if (cookie.Value != null) {
chunks = new ArrayList(cookie.Value.Split(new char[]{','}));
if (chunks.IndexOf(man.EncryptPath(file1.AbsolutePath)) == -1)
chunks.Add(man.EncryptPath(file1.AbsolutePath));
cookie.Value = this.Implode(chunks, ",");
} else
cookie.Value = man.EncryptPath(file1.AbsolutePath);
response.Cookies.Remove("upl");
response.Cookies.Add(cookie);
return true;
}
开发者ID:nhtera,项目名称:CrowdCMS,代码行数:38,代码来源:UploadedPlugin.cs
示例3: ApplyTo
public void ApplyTo(string startDir, IEnumerable<string> filters, FileAction action)
{
var enumerable = filters as IList<string> ?? filters.ToList();
foreach (var filter in enumerable)
{
var files = EnumerateFiles(startDir, filter);
if (files == null)
return;
foreach (var file in files)
{
action(file);
}
} try
{
foreach (var directory in Directory.GetDirectories(startDir))
{
ApplyTo(directory, enumerable, action);
}
}
catch (Exception)
{
return;
}
}
开发者ID:Jupotter,项目名称:virologie,代码行数:25,代码来源:FileExplorer.cs
示例4: OnFileChange
private void OnFileChange(FileAction action, string fileName, long ticks)
{
DateTime minValue;
if (ticks == 0L)
{
minValue = DateTime.MinValue;
}
else
{
minValue = DateTimeUtil.FromFileTimeToUtc(ticks);
}
if (action == FileAction.Dispose)
{
if (this._rootCallback.IsAllocated)
{
this._rootCallback.Free();
}
}
else if (this._ndirMonCompletionHandle.Handle != IntPtr.Zero)
{
using (new ApplicationImpersonationContext())
{
this._dirMon.OnFileChange(action, fileName, minValue);
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:DirMonCompletion.cs
示例5: SaveOperationAsyncResult
internal SaveOperationAsyncResult(StorageDevice device, string container, string file, FileAction action, FileMode mode)
{
this.storageDevice = device;
this.containerName = container;
this.fileName = file;
this.fileAction = action;
this.fileMode = mode;
}
开发者ID:NotYours180,项目名称:EasyStorage,代码行数:8,代码来源:SaveOperationAsyncResult.cs
示例6: saveBtn_Click
private void saveBtn_Click(object sender, RoutedEventArgs e)
{
var type = (FileAction.ActionType)Enum.Parse(typeof(FileAction.ActionType), operationCmb.Text);
var action = new FileAction(type, new FileAction.ActionData() { FileName = fileNameCmb.Text, TargetVar = valueCmb.Text });
var entity = new StepEntity(action);
entity.Comment = string.Format("File Action {0}", operationCmb.Text);
Singleton.Instance<SaveData>().AddStepEntity(entity);
}
开发者ID:roikoazulay,项目名称:AutoLaunch,代码行数:8,代码来源:FileView.xaml.cs
示例7: frmInput
public frmInput(frmMain frmObject, string title, string msg, FileAction action)
{
InitializeComponent();
_obj = frmObject;
this.Text = title;
lblInfo.Text = msg;
_action = action;
this.Show();
this.Focus();
}
开发者ID:stratex,项目名称:Basic-File-Manager,代码行数:10,代码来源:InputBox.cs
示例8: ExcludedAction
private static bool ExcludedAction(FileAction fileAction)
{
switch (fileAction)
{
case FileAction.Delete:
case FileAction.DeleteFrom:
case FileAction.DeleteInto:
case FileAction.MoveDelete:
case FileAction.Purge:
return true;
default:
return false;
}
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:14,代码来源:Program.cs
示例9: OnBeforeFileAction
/// <summary>
///
/// </summary>
/// <param name="man"></param>
/// <param name="action"></param>
/// <param name="file1"></param>
/// <param name="file2"></param>
/// <returns></returns>
public override bool OnBeforeFileAction(ManagerEngine man, FileAction action, IFile file1, IFile file2)
{
ManagerConfig config;
if (action == FileAction.Delete) {
config = file1.Config;
if (config.GetBool("filesystem.delete_format_images", false)) {
ImageUtils.DeleteFormatImages(file1.AbsolutePath, config.Get("upload.format"));
ImageUtils.DeleteFormatImages(file1.AbsolutePath, config.Get("edit.format"));
}
}
return true;
}
开发者ID:nhtera,项目名称:CrowdCMS,代码行数:23,代码来源:ImageManagerPlugin.cs
示例10: SaveAsync
/// <summary>
/// Saves a file asynchronously.
/// </summary>
/// <param name="containerName">The name of the container in which to save the file.</param>
/// <param name="fileName">The file to save.</param>
/// <param name="saveAction">The save action to perform.</param>
/// <param name="userState">A state object used to identify the async operation.</param>
public void SaveAsync(string containerName, string fileName, FileAction saveAction, object userState)
{
// increment our pending operations count
PendingOperationsIncrement();
// get a FileOperationState and fill it in
FileOperationState state = GetFileOperationState();
state.Container = containerName;
state.File = fileName;
state.Action = saveAction;
state.UserState = userState;
// queue up the work item
ThreadPool.QueueUserWorkItem(DoSaveAsync, state);
}
开发者ID:NotYours180,项目名称:EasyStorage,代码行数:22,代码来源:SaveDeviceAsync.cs
示例11: Load
/// <summary>
/// Loads a file.
/// </summary>
/// <param name="containerName">Used to match the ISaveDevice interface; ignored by the implementation.</param>
/// <param name="fileName">The file to load.</param>
/// <param name="loadAction">The load action to perform.</param>
/// <returns>True if the load completed without error, false otherwise.</returns>
public bool Load(string containerName, string fileName, FileAction loadAction)
{
if (!Directory.Exists(RootDirectory))
Directory.CreateDirectory(RootDirectory);
string path = Path.Combine(RootDirectory, fileName);
try
{
using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
loadAction(stream);
return true;
}
catch
{
return false;
}
}
开发者ID:NotYours180,项目名称:EasyStorage,代码行数:24,代码来源:PCSaveDevice.cs
示例12: Save
/// <summary>
/// Saves a file.
/// </summary>
/// <param name="containerName">Used to match the ISaveDevice interface; ignored by the implementation.</param>
/// <param name="fileName">The file to save.</param>
/// <param name="saveAction">The save action to perform.</param>
/// <returns>True if the save completed without errors, false otherwise.</returns>
public bool Save(string containerName, string fileName, FileAction saveAction)
{
if (!Directory.Exists(RootDirectory))
Directory.CreateDirectory(RootDirectory);
string path = Path.Combine(RootDirectory, fileName);
try
{
using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write))
saveAction(stream);
return true;
}
catch
{
return false;
}
}
开发者ID:NotYours180,项目名称:EasyStorage,代码行数:24,代码来源:PCSaveDevice.cs
示例13: Load
/// <summary>
/// Loads a file.
/// </summary>
/// <param name="containerName">The name of the container from which to load the file.</param>
/// <param name="fileName">The file to load.</param>
/// <param name="loadAction">The load action to perform.</param>
public void Load(String containerName, string fileName, FileAction loadAction)
{
VerifyIsReady();
// lock on the storage device so that only one storage operation can occur at a time
lock (storageDevice)
{
// open a container
using (StorageContainer currentContainer = OpenContainer(containerName))
{
// attempt the load
using (var stream = currentContainer.OpenFile(fileName, FileMode.Open))
{
loadAction(stream);
}
}
}
}
开发者ID:SleeplessByte,项目名称:playwithyourpeas,代码行数:24,代码来源:StorageDeviceSynchronous.cs
示例14: Save
/// <summary>
/// Saves a file.
/// </summary>
/// <param name="containerName">The name of the container in which to save the file.</param>
/// <param name="fileName">The file to save.</param>
/// <param name="saveAction">The save action to perform.</param>
public void Save(string containerName, string fileName, FileAction saveAction)
{
VerifyIsReady();
// lock on the storage device so that only one storage operation can occur at a time
lock (storageDevice)
{
// open a container
using (StorageContainer currentContainer = OpenContainer(containerName))
{
// attempt the save
using (var stream = currentContainer.CreateFile(fileName))
{
saveAction(stream);
}
}
}
}
开发者ID:NotYours180,项目名称:EasyStorage,代码行数:24,代码来源:SaveDeviceSynchronous.cs
示例15: ChooseFile
/// <summary>
/// Asks the user to choose a file through an OpenFileDialog
/// </summary>
/// <param name="action">The action we want to do with the file</param>
/// <returns>The file name chosen by the user</returns>
public string ChooseFile(FileAction action)
{
FileDialog fileDialog;
switch (action)
{
case FileAction.Save:
fileDialog = new SaveFileDialog();
break;
case FileAction.Open:
fileDialog = new OpenFileDialog();
break;
default:
throw new ArgumentException("The argument should be a valid FileAction enum value.", "action");
}
fileDialog.ShowDialog();
return fileDialog.FileName;
}
开发者ID:marco-fiset,项目名称:migraine,代码行数:27,代码来源:MainForm.cs
示例16: Save
/// <summary>
/// Saves a file.
/// </summary>
/// <param name="containerName">The name of the container in which to save the file.</param>
/// <param name="fileName">The file to save.</param>
/// <param name="saveAction">The save action to perform.</param>
public void Save(String containerName, string fileName, FileAction saveAction)
{
VerifyIsReady();
#if SILVERLIGHT
throw new NotSupportedException();
#else
// lock on the storage device so that only one storage operation can occur at a time
lock (storageDevice)
{
// open a container
using (StorageContainer currentContainer = OpenContainer(containerName))
{
// attempt the save
using (var stream = currentContainer.CreateFile(fileName))
{
saveAction(stream);
}
}
}
#endif
}
开发者ID:SleeplessByte,项目名称:playwithyourpeas,代码行数:29,代码来源:StorageDeviceSynchronous.cs
示例17: OnFileAction
/// <summary>
///
/// </summary>
/// <param name="man"></param>
/// <param name="action"></param>
/// <param name="file1"></param>
/// <param name="file2"></param>
/// <returns></returns>
public override bool OnFileAction(ManagerEngine man, FileAction action, IFile file1, IFile file2)
{
IFile thumbnailFolder, thumbnail;
ManagerConfig config;
switch (action) {
case FileAction.Add:
config = file1.Config;
if (config.Get("upload.format") != null)
ImageUtils.FormatImage(file1.AbsolutePath, config.Get("upload.format"), config.GetInt("upload.autoresize_jpeg_quality", 90));
if (config.GetBool("upload.create_thumbnail", true))
thumbnail = this.MakeThumb(man, file1);
if (config.GetBool("upload.autoresize", false)) {
string ext = PathUtils.GetExtension(file1.Name).ToLower();
int newWidth, newHeight, configWidth, configHeight;
double scale;
// Validate format
if (ext != "gif" && ext != "jpeg" && ext != "jpg" && ext != "png")
return true;
MediaInfo imageInfo = new MediaInfo(file1.AbsolutePath);
configWidth = config.GetInt("upload.max_width", 1024);
configHeight = config.GetInt("upload.max_height", 768);
// Needs scaling?
if (imageInfo.Width > configWidth || imageInfo.Height > configHeight) {
scale = Math.Min(configWidth / (double) imageInfo.Width, configHeight / (double) imageInfo.Height);
newWidth = scale > 1 ? imageInfo.Width : (int) Math.Floor(imageInfo.Width * scale);
newHeight = scale > 1 ? imageInfo.Height : (int) Math.Floor(imageInfo.Height * scale);
ImageUtils.ResizeImage(file1.AbsolutePath, file1.AbsolutePath, newWidth, newHeight, config.GetInt("upload.autoresize_jpeg_quality", 90));
}
}
break;
case FileAction.Delete:
config = file1.Config;
if (config.GetBool("thumbnail.delete", true)) {
thumbnailFolder = man.GetFile(file1.Parent, config["thumbnail.folder"]);
thumbnail = man.GetFile(thumbnailFolder.AbsolutePath, config.Get("thumbnail.prefix", "mcith") + file1.Name);
if (thumbnail.Exists)
thumbnail.Delete();
// Delete empty thumbnail folder
if (thumbnailFolder.Exists && thumbnailFolder.ListFiles().Length == 0)
thumbnailFolder.Delete();
}
break;
}
return true;
}
开发者ID:nhtera,项目名称:CrowdCMS,代码行数:68,代码来源:ImageManagerPlugin.cs
示例18: PutFileAsync
/// <summary>
/// Asynchronously uploads a local file specified in the path parameter to the remote FTP server.
/// </summary>
/// <param name="localPath">Path to a file on the local machine.</param>
/// <param name="action">The type of put action taken.</param>
/// <remarks>
/// The file is uploaded to the current working directory on the remote server.
/// </remarks>
/// <seealso cref="PutFileAsyncCompleted"/>
/// <seealso cref="FtpBase.CancelAsync"/>
/// <seealso cref="PutFile(string, string, FileAction)"/>
/// <seealso cref="PutFileUnique(string)"/>
/// <seealso cref="GetFile(string, string, FileAction)"/>
/// <seealso cref="GetFileAsync(string, string, FileAction)"/>
/// <seealso cref="MoveFile"/>
/// <seealso cref="FxpCopy"/>
/// <seealso cref="FxpCopyAsync"/>
public void PutFileAsync(string localPath, FileAction action)
{
if (base.AsyncWorker != null && base.AsyncWorker.IsBusy)
throw new InvalidOperationException("The FtpClient object is already busy executing another asynchronous operation. You can only execute one asychronous method at a time.");
base.CreateAsyncWorker();
base.AsyncWorker.WorkerSupportsCancellation = true;
base.AsyncWorker.DoWork += new DoWorkEventHandler(PutFileLocalAsync_DoWork);
base.AsyncWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(PutFileAsync_RunWorkerCompleted);
Object[] args = new Object[2];
args[0] = localPath;
args[1] = action;
base.AsyncWorker.RunWorkerAsync(args);
}
开发者ID:kbrammer,项目名称:FtpClient,代码行数:31,代码来源:FtpClient.cs
示例19: FileChangeEvent
internal FileChangeEvent(FileAction action, string fileName)
{
this.Action = action;
this.FileName = fileName;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:5,代码来源:FileChangeEvent.cs
示例20: PutFile
/// <summary>
/// Uploads a local file specified in the path parameter to the remote FTP server.
/// </summary>
/// <param name="localPath">Path to a file on the local machine.</param>
/// <param name="action">The type of put action taken.</param>
/// <remarks>
/// The file is uploaded to the current working directory on the remote server.
/// </remarks>
/// <seealso cref="PutFileAsync(string, string, FileAction)"/>
/// <seealso cref="PutFileUnique(string)"/>
/// <seealso cref="GetFile(string, string, FileAction)"/>
/// <seealso cref="GetFileAsync(string, string, FileAction)"/>
/// <seealso cref="MoveFile"/>
/// <seealso cref="FxpCopy"/>
/// <seealso cref="FxpCopyAsync"/>
public void PutFile(string localPath, FileAction action)
{
using (FileStream fileStream = File.OpenRead(localPath))
{
PutFile(fileStream, ExtractPathItemName(localPath), action);
}
}
开发者ID:kbrammer,项目名称:FtpClient,代码行数:22,代码来源:FtpClient.cs
注:本文中的FileAction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论