Ejemplo n.º 1
0
 private static void SetLastError(Exception ex)
 {
     if (ex is ArgumentException)
     {
         LastError = FileError.WrongFormat;
     }
     else if (ex is PathTooLongException)
     {
         LastError = FileError.WrongFormat;
     }
     else if (ex is DirectoryNotFoundException)
     {
         LastError = FileError.DirNotFound;
     }
     else if (ex is FileNotFoundException)
     {
         LastError = FileError.FileNotFound;
     }
     else if (ex is IOException)
     {
         LastError = FileError.IoException;
     }
     else
     {
         LastError = FileError.Unknow;
     }
 }
Ejemplo n.º 2
0
        /**
         * Given a job, executes its computation. The computation of a
         * Job consist in the assignment of the job to a JobExecutor
         * which has the purpose of execute the file tranfer according
         * to a specific protocol.
         * Returns the ExecutableThread on which the job is beeing managed.
         */
        public ExecutableThread scheduleJob(SendingJob job)
        {
            // Pushes the job in the list of in-service jobs
            JobsList.Sending.push(job);

            // Schedules a thread to send the packet
            JobExecutor sender = new JobExecutor(job);

            // When the transmissione ends
            sender.OnTrasmissionEnd += () => {
                // Removes the job from the active jobs list
                JobsList.Sending.remove(job.Id);
            };

            // When a connection error occours
            sender.ConnectionError += (Job j) => {
                ConnectionError?.Invoke(j);
            };


            // When a file error occours
            sender.FileError += (Exception e, Job j) => {
                FileError?.Invoke(e, j);
            };
            // Run the sender
            sender.run();

            return(sender);
        }
Ejemplo n.º 3
0
        private async Task UploadFiles()
        {
            using (var ftpClient = CreateFtpClient())
            {
                while (_Queue.TryDequeue(out var file))
                {
                    var args = new FtpEventArgs
                    {
                        File      = file,
                        FilesLeft = _Queue.Count + 1
                    };

                    try
                    {
                        FileWillUpload?.Invoke(this, args);
                        await ftpClient.UploadAsync(file);

                        FileDidUpload?.Invoke(this, args);
                    }
                    catch (Exception ex)
                    {
                        args.Message = ex.InnerException?.Message;
                        FileError?.Invoke(this, args);
                    }
                }
            }
        }
 public override void OnException(HttpActionExecutedContext actionExecutedContext)
 {
     if (actionExecutedContext.Exception != null && actionExecutedContext.Response == null)
     {
         var fileError = new FileError(actionExecutedContext.Exception);
         actionExecutedContext.Response = actionExecutedContext.Request.CreateResponse(HttpStatusCode.BadRequest, fileError);
     }
 }
Ejemplo n.º 5
0
 public AnalyseFile()
 {
     result  = new Result();
     inFile  = new FileInfo();
     outFile = new FileInfo();
     warning = new AnalyseWarning();
     error   = new FileError();
 }
 public override void OnException(HttpActionExecutedContext actionExecutedContext)
 {
     if (actionExecutedContext.Exception != null && actionExecutedContext.Response == null)
     {
         var fileError = new FileError(actionExecutedContext.Exception);
         actionExecutedContext.Response = actionExecutedContext.Request.CreateResponse(HttpStatusCode.BadRequest, fileError);
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 切换当前目录
        /// </summary>
        /// <param name="vPath">虚拟路径</param>
        /// <param name="createDirIfNotExists">目录不存在时,是否创建目录</param> //MARK: WARNING: may cause Security Issue!
        /// <returns></returns>
        public bool ChangeCurrentDirectory(string vPath, bool createDirIfNotExists = false)
        {
            string pre = VPath.NormalizeFilename(vPath, true);

            if (pre == "..")
            {
                _currentDirectory = _currentDirectory.ParentDirectory;
            }
            else if (pre == "/") //FIXED:
            {
                _currentDirectory = _rootDirectory;
            }
            else
            {
                VDirectory v;
                if (pre.StartsWith("/", StringComparison.OrdinalIgnoreCase))    //绝对虚拟路径
                {
                    v = Get(pre, true) as VDirectory;
                }
                else    //相对虚拟路径
                {
                    v = _currentDirectory.SubFiles.Find((t) => t.IsDirectory && t.Name == pre) as VDirectory;
                }
                if (v == null)
                {
                    if (!createDirIfNotExists)
                    {
                        return(false);
                    }
                    //ADDED:
                    FileError fileError = CreateDirectory(pre);
                    if (fileError == FileError.None)
                    {
                        var dir = Get(pre, true) as VDirectory;
                        if (dir != null)
                        {
                            v = dir;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                _currentDirectory = v;
            }
            _currentDirectory.Refresh();
            SetPermission(_currentDirectory, true);
            return(true);
        }
 public void OnException(ExceptionContext actionExecutedContext)
 {
     if (actionExecutedContext.Exception != null)
     {
         var fileError = new FileError(actionExecutedContext.Exception);
         actionExecutedContext.Result = new ObjectResult(fileError)
         {
             StatusCode = (int)HttpStatusCode.BadRequest
         };
     }
     LogException(actionExecutedContext.Exception);
 }
Ejemplo n.º 9
0
        /// <summary>
        /// RMD Command - RFC 959 - Section 4.1.3
        /// <para>删除文件夹</para>
        /// </summary>
        /// <param name="pathname"></param>
        /// <returns></returns>
        private Response RemoveDir(string pathname)
        {
            FileError result = _virtualFileSystem.Delete(pathname, true);

            if (result == FileError.None)
            {
                _virtualFileSystem.RefreshCurrentDirectory();
                return(GetResponse(FtpResponses.FILE_ACTION_COMPLETE));
            }

            return(GetResponse(FtpResponses.DIRECTORY_NOT_FOUND));
        }
Ejemplo n.º 10
0
 void iErrorsNotificationService.sendFileError(FileError error)
 {
     try
     {
         IManagerErrors manager = GetManager(error.Persist, error.ComolUniqueID, error.Type);
         manager.SaveFileError(error);
     }
     catch (Exception ex)
     {
         ErrorHandler pError = new ErrorHandler();
         pError.addMessageToPoisonQueue(error, ex);
     }
 }
Ejemplo n.º 11
0
 public void SaveFileError(FileError error)
 {
     try
     {
         String subject = string.Format(_template.Subject, error.ComolUniqueID);
         String body    = string.Format(_template.Body, error.SentDate.ToLongDateString(), error.UserID, error.CommunityID, error.CommunityFileID, error.BaseFileID, error.NoticeboardFileID, error.ThesisFileID, error.Message);
         DataHelpers.SendMessage(_setting, subject, body);
     }
     catch (Exception ex)
     {
         System.Diagnostics.EventLog.WriteEntry("Mail - SaveFileError ", ex.Message);
         throw ex;
     }
 }
Ejemplo n.º 12
0
        private void CheckOrdFileCount()
        {
            var files = Directory.EnumerateFiles(Directory.GetCurrentDirectory()).Where(f => f.EndsWith(".ord")).ToList();

            if (files.Count == 1)
            {
                _logger.Debug($"A másolás sikeres volt, a feldolgozás elindítása");
                var newFile = new FileInfo(files[0]);
                CopySucceeded?.Invoke(this, new SuccessFileCopyArgs(newFile));
            }
            else
            {
                _logger.Error($"A másolás végeredménye használhatatlan, mert {files.Count} fájl lett elmásolva az 1 helyett");
                FileError?.Invoke(this, new FileCountArgs(files.ToArray(), files.Count));
            }
        }
Ejemplo n.º 13
0
        /**
         * Execution of the thread
         */
        protected override void execute()
        {
            // Create a TCP/IP  socket.
            socket = new Socket(AddressFamily.InterNetwork,
                                SocketType.Stream,
                                ProtocolType.Tcp);
            // Specifies the receiver address in order to perform conncetion
            Peer       receiver     = HelloProtocol.PeersList.Instance.get(job.Task.Receiver);
            IPAddress  receiverAddr = IPAddress.Parse(receiver.Ipaddress);
            IPEndPoint remoteEP     = new IPEndPoint(receiverAddr, Settings.Instance.SERV_ACCEPTING_PORT);

            try {
                // Connect to the receiver socket
                socket.Connect(remoteEP);

                // Create a client for the specific protocol
                // The client receives the socket whith the connection established
                ClientProtocolEndpoint client = new NetworkTransmission.TnSClient(socket, new TnSProtocol(), job);

                // Executes the transmission and obtais a result
                TransferResult res = client.transfer();

                // Calls the delegate
                OnTrasmissionEnd();
            } catch (SocketException e) {
                // Remove the job from the list
                JobsList.Sending.remove(job.Id);
                // Trigger the event of conncetion error
                if (job.Status != Job.JobStatus.StoppedByLocal)
                {
                    job.Status = Job.JobStatus.ConnectionError;
                }

                ConnectionError?.Invoke(job);
            } catch (System.Exception e) {
                // Remove the job from the list
                JobsList.Sending.remove(job.Id);

                // Update the job status
                job.Status = Job.JobStatus.ConnectionError;

                FileError?.Invoke(e, job);
            } finally {
                // Close the socket
                socket.Close();
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Чтение содержимого файла
        /// </summary>
        /// <param name="filename">Полный путь к файлу</param>
        /// <returns>Бинарное содержимого файла</returns>
        public static Byte[] Read(String filename)
        {
            LastError = FileError.None;

            try
            {
                Byte[] buffer = File.ReadAllBytes(filename);

                return(buffer);
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return(null);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Создание каталога
        /// </summary>
        /// <param name="dirPath"></param>
        public static Boolean CreateDir(String dirPath)
        {
            LastError = FileError.None;

            try
            {
                Directory.CreateDirectory(dirPath);

                return(true);
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return(false);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Чтение содержимого файла как текст
        /// </summary>
        /// <param name="filename">Полный путь к файлу</param>
        /// <returns>Текстовое содержимого файла</returns>
        public static String ReadText(String filename)
        {
            LastError = FileError.None;

            try
            {
                String text = File.ReadAllText(filename);

                return(text);
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return(null);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Чтение содержимого файла как текст
        /// </summary>
        /// <param name="filename">Полный путь к файлу</param>
        /// <returns>Текстовое содержимого файла</returns>
        public static Boolean Write(String filename, Byte[] data)
        {
            LastError = FileError.None;

            try
            {
                File.WriteAllBytes(filename, data);

                return(true);
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return(false);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Чтение содержимого файла как текст
        /// </summary>
        /// <param name="filename">Полный путь к файлу</param>
        /// <returns>Текстовое содержимого файла</returns>
        public static Boolean WriteText(String filename, String text)
        {
            LastError = FileError.None;

            try
            {
                File.WriteAllText(filename, text);

                return(true);
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return(false);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Удаление файла
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static Boolean DeleteFile(String filename)
        {
            LastError = FileError.None;

            try
            {
                File.Delete(filename);

                return(true);
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return(true);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Создание каталога
        /// </summary>
        /// <param name="dirPath"></param>
        public static Boolean DeleteDir(String dirPath)
        {
            LastError = FileError.None;

            try
            {
                DirectoryInfo dir = new DirectoryInfo(dirPath);
                dir.Delete(true);

                return(true);
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return(false);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// MKD Command - RFC 959 - Section 4.1.3
        /// <para>创建文件夹</para>
        /// </summary>
        /// <param name="pathname"></param>
        /// <returns></returns>
        private Response CreateDir(string pathname)
        {
            DirectoryInfo di;
            FileError     result = _virtualFileSystem.CreateDirectory(pathname, out di);

            if (result == FileError.AlreadyExist)
            {
                return(GetResponse(FtpResponses.DIRECTORY_EXISTS));
            }
            if (result == FileError.NotFound)
            {
                return(GetResponse(FtpResponses.DIRECTORY_NOT_FOUND));
            }

            var name = di != null ? di.Name : VPath.GetFileName(pathname);

            _virtualFileSystem.RefreshCurrentDirectory();
            return(GetResponse(FtpResponses.MAKE_DIRECTORY_SUCCESS.SetData(name)));
        }
Ejemplo n.º 22
0
            void OpenFile(bool append)
            {
                try {
                    createLogFileStream();
                } catch (Exception ex) {
                    if (FileLogPrv.HandleFileError != null)
                    {
                        var fileErr = new FileError(LogFileName, ex);
                        FileLogPrv.HandleFileError(fileErr);
                        if (fileErr.NewLogFileName != null)
                        {
                            FileLogPrv.LogFileName = fileErr.NewLogFileName;
                            DetermineLastFileLogName();                         // preserve all existing logic related to 'FormatLogFileName' and rolling files
                            createLogFileStream();                              // if error occurs it is not handled recursively
                        }
                    }
                    else
                    {
                        throw;                         // do not handle by default to preserve backward compatibility
                    }
                }

                LogFileWriter = new StreamWriter(LogFileStream);

                void createLogFileStream()
                {
                    var fileInfo = new FileInfo(LogFileName);

                    // Directory.Create will check if the directory already exists,
                    // so there is no need for a "manual" check first.
                    fileInfo.Directory.Create();

                    LogFileStream = new FileStream(LogFileName, FileMode.OpenOrCreate, FileAccess.Write);
                    if (append)
                    {
                        LogFileStream.Seek(0, SeekOrigin.End);
                    }
                    else
                    {
                        LogFileStream.SetLength(0);                         // clear the file
                    }
                }
            }
Ejemplo n.º 23
0
        /// <summary>
        /// Копирование файла
        /// </summary>
        /// <param name="dest"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public static String CopyFile(String destPath, String filePath)
        {
            if (String.IsNullOrEmpty(destPath))
            {
                return("");
            }
            if (String.IsNullOrEmpty(filePath))
            {
                return("");
            }

            destPath.TrimEnd('\\');

            LastError = FileError.None;

            try
            {
                if (Directory.Exists(destPath) == false)
                {
                    Files.CreateDir(destPath);
                }

                String filename = Files.GetFileNameAndExt(filePath);
                String newPath  = destPath + "\\" + filename;

                if (File.Exists(newPath))
                {
                    Files.DeleteFile(newPath);
                }

                File.Copy(filePath, newPath);

                return(newPath);
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return("");
        }
Ejemplo n.º 24
0
        /// <summary>
        /// RNFR - RNTO - RFC 959 - Seciton 4.1.3
        /// <para>重命名</para>
        /// </summary>
        /// <param name="renameFrom"></param>
        /// <param name="renameTo"></param>
        /// <returns></returns>
        private Response Rename(string renameFrom, string renameTo)
        {
            if (string.IsNullOrWhiteSpace(renameFrom) || string.IsNullOrWhiteSpace(renameTo))
            {
                return(GetResponse(FtpResponses.FILE_ACTION_NOT_TAKEN));
            }

            FileError result = _virtualFileSystem.Rename(renameFrom, renameTo);

            if (result != FileError.None)
            {
                return(GetResponse(FtpResponses.FILE_ACTION_NOT_TAKEN));
            }
            else
            {
                _virtualFileSystem.RefreshCurrentDirectory();
                return(GetResponse(FtpResponses.FILE_ACTION_COMPLETE));
            }

            //return GetResponse(FtpResponses.FILE_ACTION_NOT_TAKEN);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Модификация данных в файле
        /// </summary>
        /// <param name="filename">Полный путь к файлу</param>
        /// <returns>Текстовое содержимого файла</returns>
        public static Boolean Modify(String filename, Byte[] data, int offset)
        {
            using (FileStream stream = File.Open(filename, FileMode.Open))
            {
                LastError = FileError.None;

                try
                {
                    stream.Position = offset;
                    stream.Write(data, 0, data.Length);

                    return(true);
                }
                catch (Exception ex)
                {
                    SetLastError(ex);
                }
            }

            return(false);
        }
Ejemplo n.º 26
0
 protected override void OnReceive(object message)
 {
     if (message is FileWrite)
     {
         string text = fileStreamReader.ReadToEnd();
         if (!String.IsNullOrEmpty(text))
         {
             reporterActor.Tell("Currently running thread: " + Thread.CurrentThread.ManagedThreadId + " --> " + text);
             reporterActor.Tell(text);
         }
     }
     else if (message is FileError)
     {
         FileError msg = message as FileError;
         reporterActor.Tell(string.Format("Tail error: {0}", msg.Reason));
     }
     else if (message is InitialRead)
     {
         InitialRead msg = message as InitialRead;
         reporterActor.Tell(msg.Text);
     }
 }
Ejemplo n.º 27
0
        public void SaveFileError(FileError error)
        {
            Database oDatabase = DatabaseFactory.CreateDatabase(DataHelpers.ConnectionString());

            using (DbConnection connection = oDatabase.CreateConnection())
            {
                connection.Open();
                try
                {
                    DbCommand oCommand = oDatabase.GetStoredProcCommand("sp_FileError_Add");
                    if (error.UniqueID == System.Guid.Empty)
                    {
                        error.UniqueID = System.Guid.NewGuid();
                    }
                    oDatabase.AddInParameter(oCommand, "@Message", System.Data.DbType.String, error.Message);
                    oDatabase.AddInParameter(oCommand, "@ComolUniqueID", System.Data.DbType.String, error.ComolUniqueID);
                    oDatabase.AddInParameter(oCommand, "@SentDate", System.Data.DbType.DateTime, error.SentDate);
                    oDatabase.AddInParameter(oCommand, "@Day", System.Data.DbType.Date, error.Day);
                    oDatabase.AddInParameter(oCommand, "@UniqueID", System.Data.DbType.Guid, error.UniqueID);
                    oDatabase.AddInParameter(oCommand, "@CommunityID", System.Data.DbType.Int32, error.CommunityID);
                    oDatabase.AddInParameter(oCommand, "@UserID", System.Data.DbType.Int32, error.UserID);
                    oDatabase.AddInParameter(oCommand, "@CommunityFileID", System.Data.DbType.Int64, error.CommunityFileID);
                    oDatabase.AddInParameter(oCommand, "@NoticeboardFileID", System.Data.DbType.Int64, error.NoticeboardFileID);
                    oDatabase.AddInParameter(oCommand, "@ThesisFileID", System.Data.DbType.Int32, error.ThesisFileID);
                    oDatabase.AddInParameter(oCommand, "@BaseFileID", System.Data.DbType.Guid, error.BaseFileID);

                    oCommand.Connection = connection;
                    if (oCommand.ExecuteNonQuery() == 0)
                    {
                        throw new Exception("no insert: sp_FileError_Add");
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("ManagerDatabase - SaveFileError", ex.Message);
                }
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Копирование файла
        /// </summary>
        /// <param name="dest"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public static String CopyFile(String destPath, String filePath)
        {
            if (String.IsNullOrEmpty(destPath)) return "";
            if (String.IsNullOrEmpty(filePath)) return "";

            destPath.TrimEnd('\\');

            LastError = FileError.None;

            try
            {
                if (Directory.Exists(destPath) == false)
                    Files.CreateDir(destPath);

                String filename = Files.GetFileNameAndExt(filePath);
                String newPath = destPath + "\\" + filename;

                if (File.Exists(newPath))
                    Files.DeleteFile(newPath);

                File.Copy(filePath, newPath);

                return newPath;
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return "";
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Модификация данных в файле
        /// </summary>
        /// <param name="filename">Полный путь к файлу</param>
        /// <returns>Текстовое содержимого файла</returns>
        public static Boolean Modify(String filename, Byte[] data, int offset)
        {
            using (FileStream stream = File.Open(filename, FileMode.Open))
            {
                LastError = FileError.None;

                try
                {
                    stream.Position = offset;
                    stream.Write(data, 0, data.Length);

                    return true;
                }
                catch (Exception ex)
                {
                    SetLastError(ex);
                }
            }

            return false;
        }
Ejemplo n.º 30
0
 private static void SetLastError(Exception ex)
 {
     if (ex is ArgumentException) LastError = FileError.WrongFormat;
     else if (ex is PathTooLongException) LastError = FileError.WrongFormat;
     else if (ex is DirectoryNotFoundException) LastError = FileError.DirNotFound;
     else if (ex is FileNotFoundException) LastError = FileError.FileNotFound;
     else if (ex is IOException) LastError = FileError.IoException;
     else
     {
         LastError = FileError.Unknow;
     }
 }
Ejemplo n.º 31
0
 public void SaveFileError(FileError error)
 {
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Чтение содержимого файла как текст
        /// </summary>
        /// <param name="filename">Полный путь к файлу</param>
        /// <returns>Текстовое содержимого файла</returns>
        public static Boolean Write(String filename, Byte[] data)
        {
            LastError = FileError.None;

            try
            {
                File.WriteAllBytes(filename, data);

                return true;
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return false;
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Чтение содержимого файла как текст
        /// </summary>
        /// <param name="filename">Полный путь к файлу</param>
        /// <returns>Текстовое содержимого файла</returns>
        public static Boolean WriteText(String filename, String text)
        {
            LastError = FileError.None;

            try
            {
                File.WriteAllText(filename, text);

                return true;
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return false;
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Чтение содержимого файла как текст
        /// </summary>
        /// <param name="filename">Полный путь к файлу</param>
        /// <returns>Текстовое содержимого файла</returns>
        public static String ReadText(String filename)
        {
            LastError = FileError.None;

            try
            {
                String text = File.ReadAllText(filename);

                return text;
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return null;
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Создание каталога
        /// </summary>
        /// <param name="dirPath"></param>
        public static Boolean CreateDir(String dirPath)
        {
            LastError = FileError.None;

            try
            {
                Directory.CreateDirectory(dirPath);

                return true;
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return false;
        }
Ejemplo n.º 36
0
 public void Handle(FileError message)
 {
     _reporterActor.Tell($"Tail error: {message.Reason}");
 }
Ejemplo n.º 37
0
        /// <summary>
        /// Удаление файла
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static Boolean DeleteFile(String filename)
        {
            LastError = FileError.None;

            try
            {
                File.Delete(filename);

                return true;
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return true;
        }
Ejemplo n.º 38
0
        /// <summary>
        /// Создание каталога
        /// </summary>
        /// <param name="dirPath"></param>
        public static Boolean DeleteDir(String dirPath)
        {
            LastError = FileError.None;

            try
            {
                DirectoryInfo dir = new DirectoryInfo(dirPath);
                dir.Delete(true);

                return true;
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return false;
        }
Ejemplo n.º 39
0
        /// <summary>
        /// Чтение содержимого файла
        /// </summary>
        /// <param name="filename">Полный путь к файлу</param>
        /// <returns>Бинарное содержимого файла</returns>
        public static Byte[] Read(String filename)
        {
            LastError = FileError.None;

            try
            {
                Byte[] buffer = File.ReadAllBytes(filename);

                return buffer;
            }
            catch (Exception ex)
            {
                SetLastError(ex);
            }

            return null;
        }
Ejemplo n.º 40
0
 public FileACK(int objectAddress, NameOfFile nof, byte nameOfSection, AcknowledgeQualifier qualifier, FileError errorCode)
     : base(objectAddress)
 {
     this.nof           = nof;
     this.nameOfSection = nameOfSection;
     this.AckQualifier  = qualifier;
     this.ErrorCode     = errorCode;
 }