Akamai.NetStorage.NetStorage.MTime C# (CSharp) Method

MTime() public method

public MTime ( string path, System.DateTime mTime = null ) : bool
path string
mTime System.DateTime
return bool
        public bool MTime(string path, DateTime? mTime = null)
        {
            //TODO: verify that this is for a file - cannot mtime on symlinks or dirs
            mTime = mTime ?? DateTime.Now;
            using (execute("PUT", path, new APIParams() { Action = "mtime", MTime = mTime })) { }
            return true;
        }

Usage Example

示例#1
0
        static void execute(string action, string user, string key, string netstorageURI,
                            string uploadfile, string outputfile, string target, string dst, bool indexZip)
        {
            if (action == null || netstorageURI == null || user == null || key == null)
            {
                help();
                return;
            }

            string[]   hostpath = netstorageURI.Split("/".ToCharArray(), 2);
            string     host     = hostpath[0];
            string     path     = hostpath[1];
            NetStorage ns       = new NetStorage(host, user, key);
            Stream     result   = null;
            bool       success  = true;

            switch (action)
            {
            case " delete":
            case "dir":
                result = ns.Dir(path);
                break;

            case "download":
                result = ns.Download(path);
                break;

            case "du":
                result = ns.DU(path);
                break;

            case "mkdir":
                success = ns.MkDir(path);
                break;

            case "mtime":
                success = ns.MTime(path);
                break;

            case "rename":
                if (dst == null)
                {
                    help();
                    return;
                }
                success = ns.Rename(path, dst);
                break;

            case "rmdir":
                success = ns.RmDir(path);
                break;

            case "stat":
                result = ns.Stat(path);
                break;

            case "symlink":
                if (target == null)
                {
                    help();
                    return;
                }
                success = ns.Symlink(path, target);
                break;

            case "upload":
                if (uploadfile == null)
                {
                    help();
                    return;
                }
                success = ns.Upload(path, new FileInfo(uploadfile), indexZip);
                break;

            default:
                help();
                return;
            }

            if (result != null)
            {
                Stream output = Console.OpenStandardOutput();
                if (outputfile != null)
                {
                    output = new FileInfo(outputfile).OpenWrite();
                }

                using (output)
                {
                    using (result)
                    {
                        byte[] buffer    = new byte[32 * 1024];
                        int    bytesRead = 0;

                        while ((bytesRead = result.Read(buffer, 0, buffer.Length)) != 0)
                        {
                            output.Write(buffer, 0, bytesRead);
                        }
                    }
                }
            }
            else if (success)
            {
                Console.Out.WriteLine("Success.");
            }
            else
            {
                Console.Error.WriteLine("Error.");
            }
        }
All Usage Examples Of Akamai.NetStorage.NetStorage::MTime