about record permissions c#
while formulating record synchronization way c# i attempted slight copy localfileitem category uses system.io.file.copy(destination.path, path, true) slight where path string.
after executing formula destination. path = "c:\\test2" this.path = "c:\\test\\f1.txt" i an difference observant i have mandatory record permissions operation c:\test, nonetheless c:\test owned myself (the tide user).
does anybody knows going on, around this?
here uncanny formula complete.
using system;
using system.collections.generic;
using system.text;
using system.io;
namespace diones.util.io
{
/// <summary>
/// an vigilant illustration record directory.
/// </summary>
open summary category fileitem : icomparable
{
stable twine path;
open twine path
{
set { this.path = value; }
{ relapse this.path; }
}
stable bool isdirectory;
open bool isdirectory
{
set { this.isdirectory = value; }
{ relapse this.isdirectory; }
}
/// <summary>
/// mislay fileitem.
/// </summary>
open summary vacant delete();
/// <summary>
/// mislay office the elements.
/// </summary>
stable summary vacant deleterecursive();
/// <summary>
/// duplicate fileitem finish directory.
/// </summary>
open summary vacant copy(fileitem filed);
/// <summary>
/// duplicate office the elements
/// finish directory.
/// </summary>
stable summary vacant copyrecursive(fileitem filed);
/// <summary>
/// creates fileitem twine path.
/// </summary>
/// <param name="path"></param>
open fileitem(string path)
{
route = path;
(path.endswith("\\") || path.endswith("/")) isdirectory = true;
else isdirectory = false;
}
/// <summary>
/// creates fileitem filesource directory.
/// </summary>
/// <param name="directory"></param>
open fileitem(filesource directory)
{
route = directory.path;
}
open overrule twine tostring()
{
relapse path;
}
open summary int compareto(object b);
}
/// <summary>
/// record office tough disk
/// </summary>
open category localfileitem : fileitem
{
open overrule vacant delete()
{
(!isdirectory) file.delete(this.path);
else deleterecursive();
}
stable overrule vacant deleterecursive()
{
directory.delete(path, true);
}
open overrule vacant copy(fileitem destination)
{
(!isdirectory) file.copy(destination.path, path, true);
else copyrecursive(destination);
}
stable overrule vacant copyrecursive(fileitem destination)
{
microsoft.visualbasic.fileio.filesystem.copydirectory(
path, destination.path, true);
}
/// <summary>
/// create's localfileitem twine path
/// </summary>
/// <param name="path"></param>
open localfileitem(string path)
: base(path)
{
}
/// <summary>
/// creates localfileitem filesource path
/// </summary>
/// <param name="path"></param>
open localfileitem(filesource path)
: base(path)
{
}
open overrule int compareto(object obj)
{
(obj fileitem)
{
fileitem fi = (fileitem)obj;
(file.getcreationtime(this.path).compareto
(file.getcreationtime(fi.path)) > 0) relapse 1;
else (file.getcreationtime(this.path).compareto
(file.getcreationtime(fi.path)) < 0) relapse -1;
else
{
(file.getlastwritetime(this.path).compareto
(file.getlastwritetime(fi.path)) < 0) relapse -1;
else (file.getlastwritetime(this.path).compareto
(file.getlastwritetime(fi.path)) > 0) relapse 1;
else relapse 0;
}
}
else
pitch new argumentexception("obj isn't fileitem");
}
}
}
Comments
Post a Comment