Beispiel #1
0
        private static void BuildStream(string workspacePath, string[] folders, List <ResourceBuilderTO> streams)
        {
            var dir = new DirectoryWrapper();

            foreach (var path in folders.Where(f => !string.IsNullOrEmpty(f)).Select(f => Path.Combine(workspacePath, f)))
            {
                if (!Directory.Exists(path))
                {
                    continue;
                }
                var files = dir.GetFilesByExtensions(path, ".xml", ".bite");
                foreach (var file in files)
                {
                    var fa = File.GetAttributes(file);

                    if ((fa & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                    {
                        Dev2Logger.Info("Removed READONLY Flag from [ " + file + " ]", GlobalConstants.WarewolfInfo);
                        File.SetAttributes(file, FileAttributes.Normal);
                    }

                    // Use the FileStream class, which has an option that causes asynchronous I/O to occur at the operating system level.
                    // In many cases, this will avoid blocking a ThreadPool thread.
                    var sourceStream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 4096, true);
                    streams.Add(new ResourceBuilderTO {
                        _filePath = file, _fileStream = sourceStream
                    });
                }
            }
        }