Serialize converters were added
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DataAccess.FileDialogs
|
||||
{
|
||||
public class FileDialogOpener
|
||||
{
|
||||
public void OpenFileAndRead()
|
||||
{
|
||||
// Create an instance of OpenFileDialog
|
||||
using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
||||
{
|
||||
// Set filter options and filter index
|
||||
openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
|
||||
openFileDialog.FilterIndex = 1;
|
||||
openFileDialog.Multiselect = false; // Set to true if you want to allow multiple file selection
|
||||
openFileDialog.Title = "Select a File";
|
||||
|
||||
// Show the dialog and get result
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// Get the path of the selected file
|
||||
string selectedFilePath = openFileDialog.FileName;
|
||||
|
||||
// Read the content of the file
|
||||
try
|
||||
{
|
||||
string fileContent = File.ReadAllText(selectedFilePath);
|
||||
Console.WriteLine($"File Content of '{selectedFilePath}':");
|
||||
Console.WriteLine(fileContent);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Console.WriteLine($"An error occurred while reading the file: {ex.Message}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("File selection was cancelled.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,10 +10,6 @@ namespace DataAccess.FileDialogs
|
||||
{
|
||||
internal class FileStorage
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
public class FileStorageManager
|
||||
{
|
||||
@@ -109,30 +105,30 @@ class Program
|
||||
[STAThread] // Required for OpenFileDialog
|
||||
static void Main()
|
||||
{
|
||||
var fileStorageManager = new FileStorageManager();
|
||||
//var fileStorageManager = new FileStorageManager();
|
||||
|
||||
// Open files and add them to the storage
|
||||
fileStorageManager.OpenFile();
|
||||
//// Open files and add them to the storage
|
||||
//fileStorageManager.OpenFile();
|
||||
|
||||
// List all opened files
|
||||
Console.WriteLine("\nOpened Files:");
|
||||
fileStorageManager.ListOpenedFiles();
|
||||
//// List all opened files
|
||||
//Console.WriteLine("\nOpened Files:");
|
||||
//fileStorageManager.ListOpenedFiles();
|
||||
|
||||
// Example: Read content of the first opened file (if any)
|
||||
var openedFiles = new List<Guid>(fileStorageManager._openedFiles.Keys);
|
||||
if (openedFiles.Count > 0)
|
||||
{
|
||||
var firstFileId = openedFiles[0];
|
||||
Console.WriteLine($"\nReading content of the first opened file (ID: {firstFileId}):");
|
||||
string content = fileStorageManager.ReadFileContent(firstFileId);
|
||||
Console.WriteLine(content);
|
||||
}
|
||||
//// Example: Read content of the first opened file (if any)
|
||||
//var openedFiles = new List<Guid>(fileStorageManager._openedFiles.Keys);
|
||||
//if (openedFiles.Count > 0)
|
||||
//{
|
||||
// var firstFileId = openedFiles[0];
|
||||
// Console.WriteLine($"\nReading content of the first opened file (ID: {firstFileId}):");
|
||||
// string content = fileStorageManager.ReadFileContent(firstFileId);
|
||||
// Console.WriteLine(content);
|
||||
//}
|
||||
|
||||
// Close all files
|
||||
foreach (var fileId in openedFiles)
|
||||
{
|
||||
fileStorageManager.CloseFile(fileId);
|
||||
}
|
||||
//// Close all files
|
||||
//foreach (var fileId in openedFiles)
|
||||
//{
|
||||
// fileStorageManager.CloseFile(fileId);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user