예제 #1
0
        public void SaveFile(string filePath)
        {
            //In order to get the data file
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath);

            File f = new File()
            {
                Name         = fileInfo.Name,
                Size         = fileInfo.Length,
                CreationDate = fileInfo.CreationTime
            };

            string fileTypeName = fileInfo.Extension.Replace(".", "");
            var    fileType     = _fileTypeRepository.GetFileType(fileTypeName);

            if (fileType != null)
            {
                f.FileTypeId = fileType.FileTypeId;
            }
            else
            {
                FileType ft = new FileType();
                ft.TypeName = fileTypeName;
                _fileTypeRepository.AddFileType(ft);
                f.FileTypeId = ft.FileTypeId;
            }
            _fileRepository.AddFile(f);
        }
예제 #2
0
        public void SaveFile(string filePath)
        {
            //get the extension from fileName
            //string extension = fileName.Split('.')[1];


            //In order to get the data file
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath);

            File f = new File()
            {
                Name         = fileInfo.Name,
                Size         = fileInfo.Length,
                CreationDate = fileInfo.CreationTime
            };


            var fileType = _fileTypeRepository.GetFileType(fileInfo.Extension.Replace(".", ""));


            if (fileType != null)
            {
                f.FileTypeId = fileType.FileTypeId;
            }
            _fileRepository.WriteFile(f);
        }