本文整理汇总了C#中System.IO.FileInfo.GetMimeType方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.FileInfo.GetMimeType方法的具体用法?C# System.IO.FileInfo.GetMimeType怎么用?C# System.IO.FileInfo.GetMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了System.IO.FileInfo.GetMimeType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Upload
public void Upload(string path)
{
if (!string.IsNullOrEmpty(path) && CanUpload)
{
var fi = new System.IO.FileInfo(path);
int id = DataContext.CreateBlob(fi, fi.GetMimeType());
File.Blob = DataContext.Find<Zetbox.App.Base.Blob>(id);
File.Name = File.Blob.OriginalName;
}
}
示例2: Upload
public static void Upload(File obj)
{
// UI Code in Custom Actions!
// ASP.NET would have a big Problem with that function
string path = _factory.GetSourceFileNameFromUser();
if (!string.IsNullOrEmpty(path))
{
var fi = new System.IO.FileInfo(path);
int id = obj.Context.CreateBlob(fi, fi.GetMimeType());
obj.Blob = obj.Context.Find<Zetbox.App.Base.Blob>(id);
obj.Name = obj.Blob.OriginalName;
}
}
示例3: OnDrop
public override bool OnDrop(object data)
{
var files = data as string[];
if (files == null) return base.OnDrop(data);
var newScope = ViewModelFactory.CreateNewScope();
var newCtx = newScope.ViewModelFactory.CreateNewContext();
var module = newCtx.Find<Module>(CurrentModule.ID);
var objects = new List<IDataObject>();
foreach (var file in files)
{
try
{
var ext = System.IO.Path.GetExtension(file).ToLower();
switch(ext)
{
case ".png":
case ".jpg":
case ".bmp":
case ".tiff":
case ".gif":
case ".ico":
var obj = newCtx.Create<Icon>();
var fi = new System.IO.FileInfo(file);
int id = newCtx.CreateBlob(fi, fi.GetMimeType());
obj.Blob = newCtx.Find<Zetbox.App.Base.Blob>(id);
obj.IconFile = obj.Blob.OriginalName;
obj.Module = module;
objects.Add(obj);
break;
}
}
catch (Exception ex)
{
// not an xml...
Zetbox.API.Utils.Logging.Client.Error("Unable to import icon.", ex);
}
}
if (objects.Count > 0)
{
var newWorkspace = ObjectEditor.WorkspaceViewModel.Create(newScope.Scope, newCtx);
newScope.ViewModelFactory.ShowModel(newWorkspace, true);
foreach (var obj in objects)
{
newWorkspace.ShowObject(obj, activate: false);
}
newScope.ViewModelFactory.CreateDelayedTask(newWorkspace, () =>
{
newWorkspace.SelectedItem = newWorkspace.Items.FirstOrDefault();
}).Trigger();
}
else
{
newScope.Dispose();
}
return true;
}