本文整理汇总了C#中System.IO.FileSystem.UpdateFileInfo方法的典型用法代码示例。如果您正苦于以下问题:C# FileSystem.UpdateFileInfo方法的具体用法?C# FileSystem.UpdateFileInfo怎么用?C# FileSystem.UpdateFileInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileSystem
的用法示例。
在下文中一共展示了FileSystem.UpdateFileInfo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Export
/// <summary>
/// Export data into CSV format
/// </summary>
public CFile Export(FileSystem fs, ExportRow.ExportRowList rows)
{
int i;
MemoryStream csvstream = new MemoryStream();
StreamWriter csvwriter = new StreamWriter(csvstream);
//Write the data out in CSV style rows
foreach (ExportRow row in rows) {
for (i = 0; i < row.Fields.Count; i++) {
csvwriter.Write(row.Fields[i]);
if (i < row.Fields.Count-1)
csvwriter.Write(",");
}
csvwriter.WriteLine();
}
csvwriter.Flush();
//Commit to a temp file within the FS
//Create a temp file
Guid guid = Guid.NewGuid();
CFile expfile = fs.CreateFile(@"c:\system\export\" + guid.ToString(), false,
new CFilePermission.FilePermissionList() );
expfile.Name = expfile.ID + ".csv";
fs.UpdateFileInfo(expfile, false);
//Commit the data
csvstream.Seek(0, SeekOrigin.Begin);
expfile.RawData = Globals.ReadStream(csvstream, (int) csvstream.Length);
fs.Edit(expfile);
fs.Save(expfile);
csvwriter.Close();
return expfile;
}
示例2: Create
/// <summary>
/// Create the course
/// </summary>
public bool Create(string name, string number, string instructor)
{
Course course = new Course();
//TODO: Verify these values
course.Name = name;
course.Number = number;
//Create course
m_dp.CreateCourse(course);
//Get all data
course = GetInfo(course.ID);
//Define default roles
CourseRole role = new CourseRole();
role.CourseID = course.ID;
role.Name = "Student"; role.Staff = false;
m_dp.CreateCourseRole(role);
role.Name = "TA"; role.Staff = true;
m_dp.CreateCourseRole(role);
role.Name = "Instructor"; role.Staff = true;
m_dp.CreateCourseRole(role);
//Assign filesys permissions
CourseRole student = GetRoleInfo("Student", course.ID);
CourseRole ta = GetRoleInfo("TA", course.ID);
CourseRole ins = GetRoleInfo("Instructor", course.ID);
CFilePermission.FilePermissionList full = new CFilePermission.FilePermissionList();
full.AddRange(CFilePermission.CreateFullAccess(ta.PrincipalID));
full.AddRange(CFilePermission.CreateFullAccess(ins.PrincipalID));
full.Add(new CFilePermission(student.PrincipalID, FileAction.READ, true));
//Create content area
FileSystem fs = new FileSystem(m_ident);
string cpath = @"c:\ccontent\" + course.ID;
CFile cdir = fs.CreateDirectory(cpath, false, full);
course.ContentID = cdir.ID;
Update(course);
CFile ldir = fs.CreateDirectory(cpath + @"\" + "lnotes", false, null);
ldir.Alias = "Lecture Notes"; fs.UpdateFileInfo(ldir, false);
//Put operator in course temporarily
m_dp.CreateCourseMember(m_ident.Name, course.ID, "Instructor", null);
//Assign course perms
CreatePermissions(course.ID, course.ID, Permission.COURSE);
if (instructor != m_ident.Name) {
//Add instructor
AddUser(instructor, "Instructor", course.ID, null);
//Take operator out
RemoveUser(m_ident.Name, course.ID);
}
return true;
}
示例3: Update
/// <summary>
/// Load submission directory with new files, updates time
/// </summary>
public bool Update(Submission sub, IExternalSource files)
{
FileSystem fs = new FileSystem(m_ident);
bool markcmp, unmarkcmp, defunct;
//Get old sub
Components.Submission oldsub = GetInfo(sub.ID);
markcmp = (oldsub.Status == Components.Submission.UNGRADED &&
sub.Status == Components.Submission.GRADED);
unmarkcmp = (oldsub.Status == Components.Submission.GRADED &&
sub.Status == Components.Submission.UNGRADED);
defunct = (oldsub.Status != Components.Submission.DEFUNCT &&
sub.Status == Components.Submission.DEFUNCT);
//Make sure toplevel zone directory exists
CFile subdir = fs.GetFile(@"c:\subs");
if (null == subdir)
subdir = fs.CreateDirectory(@"c:\subs", true, null, false);
//Build file perms
CFilePermission.FilePermissionList perms = new CFilePermission.FilePermissionList();
int courseID = new Assignments(m_ident).GetInfo(sub.AsstID).CourseID;
CourseRole.CourseRoleList staff = new Courses(m_ident).GetTypedRoles(courseID, true, null);
foreach (CourseRole role in staff)
perms.AddRange(CFilePermission.CreateFullAccess(role.PrincipalID));
perms.AddRange(CFilePermission.CreateOprFullAccess(sub.PrincipalID));
//Create zone directory
CFile esubdir;
string zpath = @"c:\subs\" + sub.ID;
if (null == (esubdir = fs.GetFile(zpath))) {
esubdir = fs.CreateDirectory(zpath, false, perms, false);
esubdir.SpecType = CFile.SpecialType.SUBMISSION;
string name = new Principals(m_ident).GetInfo(sub.PrincipalID).Name;
esubdir.Alias = String.Format("{0}: {1}",
name, GetNextSubmission(sub.AsstID, sub.PrincipalID));
fs.UpdateFileInfo(esubdir, false);
}
//Update sub entry
sub.LocationID = esubdir.ID;
m_dp.UpdateSubmission(sub);
//Load files
try {
fs.ImportData(zpath, files, false, false); //Import the data
} catch (Exception) {
throw new DataAccessException("Invalid external file source. This means the system does " +
"not understand how to extract files from the source. Please create a valid source");
}
//Verify submission structure
VerifyFormat(sub.AsstID, zpath);
//Log
if (markcmp)
Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " completed", sub.ID);
else if (unmarkcmp)
Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " incomplete", sub.ID);
else if (defunct)
Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " defunct", sub.ID);
return true;
}
示例4: cmdUrlUpload_Click
private void cmdUrlUpload_Click(object sender, System.EventArgs e)
{
FileSystem fs = new FileSystem(Globals.CurrentIdentity);
CFile file = fs.GetFile(GetFileID());
try {
//Save Url data
fs.Edit(file);
file.Data = txtUrl.Text.ToCharArray();
fs.Save(file);
//Update file
file.Name = file.ID + ".url";
fs.UpdateFileInfo(file, false);
} catch (Exception er) {
PageLinkError(er.Message);
}
BindData();
if (Refresh != null)
Refresh(this, new RefreshEventArgs("", true, false));
}
示例5: cmdUpdate_Click
private void cmdUpdate_Click(object sender, EventArgs e)
{
FileSystem fs;
CFile file = (fs = new FileSystem(Globals.CurrentIdentity)).GetFile(GetFileID());
file.Alias = txtName.Text; file.Description = txtDesc.Text;
string tyext = txtType.Text;
if (!tyext.StartsWith("."))
tyext = "." + tyext;
file.Name = Path.GetFileNameWithoutExtension(file.Name) + tyext;
try {
fs.UpdateFileInfo(file, false);
} catch (DataAccessException er) {
PageError(er.Message);
} catch (FileOperationException er) {
PageError(er.Message);
}
if (Refresh != null)
Refresh(this, new RefreshEventArgs("", true, false));
}
示例6: cmdDataUpload_Click
private void cmdDataUpload_Click(object sender, EventArgs e)
{
if (ufContent.PostedFile.ContentLength > 0) {
FileSystem fs = new FileSystem(Globals.CurrentIdentity);
CFile file = fs.GetFile(GetFileID());
try {
fs.Edit(file);
byte[] content = Globals.ReadStream(
ufContent.PostedFile.InputStream, ufContent.PostedFile.ContentLength);
file.RawData = content;
fs.Save(file);
file.Name = file.ID + Path.GetFileName(ufContent.PostedFile.FileName);
fs.UpdateFileInfo(file, false);
} catch (Exception er) {
PageUpError(er.Message);
}
if (Refresh != null)
Refresh(this, new RefreshEventArgs("", true, false));
}
else
PageUpError("Must specify a local file to upload");
BindData();
}
示例7: dgFiles_UpdateCommand
private void dgFiles_UpdateCommand(object source, DataGridCommandEventArgs e)
{
FileSystem fs = new FileSystem(Globals.CurrentIdentity);
TextBox txtName = e.Item.FindControl("txtName") as TextBox;
int fileID = (int) dgFiles.DataKeys[e.Item.ItemIndex];
CFile file = fs.GetFile(fileID);
if (file.Alias == file.Name)
file.Name = txtName.Text;
file.Alias = txtName.Text;
try {
fs.UpdateFileInfo(file, false);
} catch (FileOperationException er) {
DisplayMessage(er.Message);
}
dgFiles.EditItemIndex = -1;
UpdateTreeNode(tvFiles.GetNodeFromIndex(tvFiles.SelectedNodeIndex), true);
BindFileGrid();
}
示例8: tb_CreateFolder
private bool tb_CreateFolder(object sender, EventArgs e)
{
FileSystem fs = new FileSystem(Globals.CurrentIdentity);
CFile par = fs.GetFile(GetCurrentFileID());
string path = par.FullPath + @"\" + "newfolder";
try {
CFile fold = fs.CreateDirectory(path, false, null);
fold.Alias = "New Folder";
fold.Name = fold.ID + fold.Name;
fs.UpdateFileInfo(fold, false);
} catch (FileOperationException er) {
PageError(er.Message);
return false;
}
TreeNode node = GetCurrentNode();
LoadNode(node);
node.Expanded = true;
return true;
}
示例9: tb_CreateDocument
private bool tb_CreateDocument(object sender, EventArgs e)
{
FileSystem fs = new FileSystem(Globals.CurrentIdentity);
CFile par = fs.GetFile(GetCurrentFileID());
string path = par.FullPath + @"\" + "newdoc.txt";
try {
CFile doc = fs.CreateFile(path, false, null);
doc.Alias = "New Document";
doc.Name = doc.ID + doc.Name;
fs.UpdateFileInfo(doc, false);
} catch (FileOperationException er) {
PageError(er.Message);
return false;
}
TreeNode node = GetCurrentNode();
LoadNode(node);
node.Expanded = true;
return true;
}