Ejemplo n.º 1
0
        static public eErrorType sendFile(XboxConsole console, string localName, string remoteName, bool createDir, bool onlyIfNewer)
        {
            if (console == null)
            {
                return(eErrorType.cNotConnected);
            }

            eErrorType res = eErrorType.c*K;

            try
            {
                if (createDir)
                {
                    string path = remoteName;
                    int    i    = path.LastIndexOf('\\');
                    if (i >= 0)
                    {
                        path = path.Substring(0, i);
                    }
                    createDirectory(console, path);
                }

                bool     gotLocalDateTime = false;
                DateTime localDateTime    = DateTime.Now;
                try
                {
                    localDateTime    = File.GetLastWriteTime(localName);
                    gotLocalDateTime = true;
                }
                catch { }

                if (onlyIfNewer && gotLocalDateTime)
                {
                    IXboxFile fileObject = null;
                    try
                    {
                        fileObject = console.GetFileObject(remoteName);
                    }
                    catch { }
                    if (fileObject != null)
                    {
                        DateTime remoteDateTime = (DateTime)fileObject.ChangeTime;
                        if (localDateTime <= remoteDateTime)
                        {
                            return(res);
                        }
                    }
                }

                console.SendFile(localName, remoteName);
            }
            catch (Exception e)
            {
                res = errorCatch(e);
            }
            return(res);
        }