From 1a1c8e71fcd14858f595029f089b2d4a00202b32 Mon Sep 17 00:00:00 2001
From: ogi <Administrator@S-OGI-PC>
Date: Fri, 05 Dec 2025 09:24:16 +0900
Subject: [PATCH] プロジェクトファイルを追加。

---
 HotelPms.Share/IO/FileOperation.cs |  265 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 265 insertions(+), 0 deletions(-)

diff --git a/HotelPms.Share/IO/FileOperation.cs b/HotelPms.Share/IO/FileOperation.cs
new file mode 100644
index 0000000..100ca4d
--- /dev/null
+++ b/HotelPms.Share/IO/FileOperation.cs
@@ -0,0 +1,265 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+
+namespace HotelPms.Share.IO
+{
+    public class FileOperation
+    {
+        [System.Runtime.InteropServices.DllImport("shell32.dll")]
+        private static extern int ExtractIconEx(string lpszFile, int niconIndex, ref IntPtr phiconLarge, ref IntPtr phiconSmall, int nIcons);
+
+        /// <summary>�w��PATH�ňꊇ�R�s�[����</summary>
+        /// <param name="hsSrcDir">���p�[�X</param>
+        /// <param name="hsDstDir">�ڕW�p�[�X</param>
+        /// <returns>bool</returns>
+        public static bool CopyTree(string hsSrcDir, string hsDstDir)
+        {
+            try
+            {
+                //�ڕW�p�[�X���Ȃ���΁A���B
+                if (!Directory.Exists(hsDstDir))
+                {
+                    Directory.CreateDirectory(hsDstDir);
+                }
+
+                //�t�@�C�����R�s�[
+                string[] wvFileArray = Directory.GetFiles(hsSrcDir);
+                if (wvFileArray.Length > 0)
+                {
+                    foreach (string wsCurfile in wvFileArray)
+                    {
+                        string dstFile = hsDstDir + Path.DirectorySeparatorChar + Path.GetFileName(wsCurfile);
+                        Delete(dstFile);
+                        File.Copy(wsCurfile, dstFile, true);
+                    }
+                }
+
+                //�q�t�H���_���R�s�[
+                string wsCurSrcDir = null;
+                string wsCurFullDstDir = null;
+
+                string[] wvDirArray = Directory.GetDirectories(hsSrcDir);
+
+                if (wvDirArray.Length > 0)
+                {
+                    foreach (string wsCurFullSrcDir in wvDirArray)
+                    {
+                        wsCurSrcDir = wsCurFullSrcDir.Substring(wsCurFullSrcDir.LastIndexOf(Path.DirectorySeparatorChar) + 1);
+                        wsCurFullDstDir = hsDstDir + Path.DirectorySeparatorChar + wsCurSrcDir;
+
+                        CopyTree(wsCurFullSrcDir, wsCurFullDstDir);
+                    }
+                }
+
+                return true;
+            }
+            catch
+            {
+                return false;
+            }
+
+        }
+
+        public static List<string> GetDirList(string rootDir)
+        {
+            List<string> retDir = new List<string>();
+            string[] dirList = Directory.GetDirectories(rootDir);
+            retDir.AddRange(dirList);
+
+            foreach (string item in dirList)
+            {
+                retDir.AddRange(GetDirList(item));
+            }
+
+            return retDir;
+        }
+
+        /// <summary>�w��PATH�Ńt�@�C���ꗗ���擾����</summary>
+        /// <param name="hsSrcDir">���p�[�X</param>
+        /// <param name="hoFileList">�t�@�C���ꗗ</param>
+        /// <returns>bool</returns>
+        public static bool GetFileList(string hsSrcDir, ref List<string> hoFileList)
+        {
+            return GetFileList(hsSrcDir, ref hoFileList, "*");
+        }
+
+        /// <summary>�w��PATH�Ńt�@�C���ꗗ���擾����</summary>
+        /// <param name="hsSrcDir">���p�[�X</param>
+        /// <param name="hoFileList">�t�@�C���ꗗ</param>
+        /// <param name="hsSearchPattern">�t�@�C���̃^�C�v(�� *.txt�A*.sql��)</param>
+        /// <returns>bool</returns>
+        public static bool GetFileList(string hsSrcDir, ref List<string> hoFileList, string hsSearchPattern)
+        {
+            try
+            {
+                string[] wvFileArray = Directory.GetFiles(hsSrcDir, hsSearchPattern);
+                if (wvFileArray.Length > 0)
+                {
+                    foreach (string wsCurfile in wvFileArray)
+                    {
+                        hoFileList.Add(wsCurfile);
+                    }
+                }
+
+                string[] wvDirArray = Directory.GetDirectories(hsSrcDir);
+
+                if (wvDirArray.Length > 0)
+                {
+                    foreach (string wsCurFullSrcDir in wvDirArray)
+                    {
+                        GetFileList(wsCurFullSrcDir, ref  hoFileList, hsSearchPattern);
+                    }
+                }
+
+                return true;
+            }
+            catch
+            {
+                return false;
+            }
+        }
+
+        public static void DeleteFile(string fileName)
+        {
+            try
+            {
+                FileInfo fi = new FileInfo(fileName);
+                if ((fi.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
+                {
+                    fi.Attributes = FileAttributes.Normal;
+                }
+
+                File.Delete(fileName);
+            }
+            catch { }
+        }
+
+        /// <summary>�t�@�C�����폜����</summary>
+        /// <param name="fileName">�t�@�C����</param>
+        /// <returns>bool</returns>
+        public static bool Delete(string fileName)
+        {
+            try
+            {
+                FileInfo fi = new FileInfo(fileName);
+                if ((fi.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
+                {
+                    fi.Attributes = FileAttributes.Normal;
+                }
+
+                File.Delete(fileName);
+
+                return true;
+            }
+            catch
+            {
+                return false;
+            }
+        }
+
+        /// <summary>�t�@�C���̎�ނō폜����</summary>
+        /// <param name="hsSrcDir">�p�[�X</param>
+        /// <param name="hsSearchPattern">�t�@�C���̎��(�� *.txt�A*.sql��)</</param>
+        /// <returns>bool</returns>
+        public static bool Delete(string hsSrcDir, string[] hsSearchPattern)
+        {
+            try
+            {
+                List<string> hoList = new List<string>();
+                for (int i = 0; i < hsSearchPattern.Length; i++)
+                {
+                    GetFileList(hsSrcDir, ref  hoList, hsSearchPattern[i]);
+                }
+
+                for (int i = 0; i < hoList.Count; i++)
+                {
+                    FileInfo fi = new FileInfo(hoList[i].ToString());
+                    if ((fi.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
+                    {
+                        fi.Attributes = FileAttributes.Normal;
+                    }
+
+                    File.Delete(hoList[i].ToString());
+                }
+
+                hoList.Clear();
+
+                return true;
+            }
+            catch
+            {
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// �ǂݎ���p���O��
+        /// </summary>
+        /// <param name="filePath"></param>
+        /// <returns></returns>
+        public static bool UnReadOnly(string filePath)
+        {
+            try
+            {
+                FileInfo fi = new FileInfo(filePath);
+                if ((fi.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
+                {
+                    fi.Attributes = FileAttributes.Normal;
+                }
+                return true;
+            }
+            catch
+            {
+                return false;
+            }
+        }
+
+        /// <summary>�SPath�폜����</summary>
+        /// <param name="aimpath">�p�[�X</param>
+        /// <returns>bool</returns>
+        public static bool DeleteDir(string aimpath)
+        {
+            try
+            {
+                if (aimpath[aimpath.Length - 1] != Path.DirectorySeparatorChar)
+                {
+                    aimpath += Path.DirectorySeparatorChar;
+                }
+                string[] filelist = Directory.GetFileSystemEntries(aimpath);
+                foreach (string file in filelist)
+                {
+                    if (Directory.Exists(file))
+                    {
+                        DeleteDir(aimpath + Path.GetFileName(file));
+                    }
+                    else
+                    {
+                        string filePath = aimpath + Path.GetFileName(file);
+                        UnReadOnly(filePath);
+                        File.Delete(filePath);
+                    }
+                }
+                Directory.Delete(aimpath, true);
+                return true;
+            }
+            catch
+            {
+                return false;
+            }
+        }
+
+        ///// <summary>
+        ///// �t�@�C���̃R�s�[
+        ///// </summary>
+        ///// <param name="fileList"></param>
+        //public static void CopyToClipboard(System.Collections.Specialized.StringCollection fileList)
+        //{
+        //    //System.Collections.Specialized.StringCollection strcoll = new System.Collections.Specialized.StringCollection();
+        //    //strcoll.Add(System.Windows.Forms.Application.ExecutablePath);
+        //    //strcoll.Add(Application.StartupPath + @"\GoogleJapaneseInputSetup.exe");
+        //    Clipboard.SetFileDropList(fileList);
+        //}
+    }
+}

--
Gitblit v1.10.0