質問するログイン新規登録

回答編集履歴

2

見直しキャンペーン中

2023/07/30 06:53

投稿

TN8001
TN8001

スコア10263

answer CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
  ---
26
26
 
27
- ```C#
27
+ ```cs
28
28
  using System.IO;
29
29
  using System.Linq;
30
30
  using System.Text;
@@ -111,7 +111,7 @@
111
111
  ---
112
112
 
113
113
  追記 しょーもない解決策orz
114
- ```C#
114
+ ```cs
115
115
  using System.IO;
116
116
  using System.Linq;
117
117
  using System.Text;

1

しょーもない解決策

2022/04/20 11:40

投稿

TN8001
TN8001

スコア10263

answer CHANGED
@@ -107,3 +107,85 @@
107
107
  }
108
108
  }
109
109
  ```
110
+
111
+ ---
112
+
113
+ 追記 しょーもない解決策orz
114
+ ```C#
115
+ using System.IO;
116
+ using System.Linq;
117
+ using System.Text;
118
+ using System.Windows.Forms;
119
+ using Microsoft.WindowsAPICodePack.Controls;
120
+ using Microsoft.WindowsAPICodePack.Controls.WindowsForms;
121
+ using Microsoft.WindowsAPICodePack.Shell;
122
+ using Microsoft.WindowsAPICodePack.Shell.PropertySystem;
123
+
124
+ namespace Q7dnj7xj3xxesgf
125
+ {
126
+ public partial class Form1 : Form
127
+ {
128
+ public Form1()
129
+ {
130
+ InitializeComponent();
131
+
132
+ File.WriteAllText("foobar.utf8.txt", "ほげぴよ", new UTF8Encoding(true));
133
+ File.WriteAllText("foobar.utf8.log", "ほげぴよ", new UTF8Encoding(true)); // txtじゃないと中身まで見てくれない模様
134
+ File.WriteAllText("foobar.utf8n.txt", "ほげぴよ", new UTF8Encoding(false)); // bomなしも中身まで見てくれない模様
135
+ File.WriteAllText("foobar.sjis.txt", "ほげぴよ", Encoding.GetEncoding("shift-jis"));
136
+
137
+ var splitContainer1 = new SplitContainer { Dock = DockStyle.Fill, Parent = this, };
138
+ var textBox1 = new TextBox { Dock = DockStyle.Top, Parent = this, };
139
+
140
+ var listView1 = new ListView
141
+ {
142
+ Dock = DockStyle.Fill,
143
+ Parent = splitContainer1.Panel1,
144
+ View = View.Details,
145
+ };
146
+ listView1.Columns.Add("名前", 200);
147
+ foreach (var f in Directory.EnumerateFiles(Application.StartupPath))
148
+ {
149
+ var item = new ListViewItem { Tag = f, Text = Path.GetFileName(f), };
150
+ listView1.Items.Add(item);
151
+ }
152
+ listView1.ItemDrag += (s, e) =>
153
+ {
154
+ var paths = listView1.SelectedItems.Cast<ListViewItem>()
155
+ .Select(x => (string)x.Tag).ToArray();
156
+ var dataObj = new DataObject(DataFormats.FileDrop, paths);
157
+ listView1.DoDragDrop(dataObj, DragDropEffects.Copy);
158
+ };
159
+
160
+
161
+ var explorerBrowser1 = new ExplorerBrowser
162
+ {
163
+ Dock = DockStyle.Fill,
164
+ Parent = splitContainer1.Panel2,
165
+ };
166
+ explorerBrowser1.NavigationOptions.PaneVisibility.Navigation = PaneVisibilityState.Hide;
167
+ explorerBrowser1.NavigationOptions.PaneVisibility.Commands = PaneVisibilityState.Hide;
168
+ explorerBrowser1.NavigationComplete += (s, e) =>
169
+ {
170
+ // とりあえずの飛ばした先なら本当にやりたい検索(う~~んどうなのよw
171
+ if (e.NewLocation == (ShellObject)KnownFolders.Computer)
172
+ {
173
+ var sc1 = SearchConditionFactory.CreateLeafCondition(SystemProperties.System.FileName,
174
+ textBox1.Text, SearchConditionOperation.ValueContains);
175
+ var folder = (ShellContainer)ShellObject.FromParsingName(Application.StartupPath);
176
+ var ssf = new ShellSearchFolder(sc1, folder);
177
+ explorerBrowser1.Navigate(ssf);
178
+ }
179
+ };
180
+
181
+ textBox1.TextChanged += (s, e) =>
182
+ {
183
+ // とりあえずどっかに飛ばす^^;
184
+ explorerBrowser1.Navigate((ShellObject)KnownFolders.Computer);
185
+ };
186
+
187
+ explorerBrowser1.Navigate((ShellObject)KnownFolders.Computer);
188
+ }
189
+ }
190
+ }
191
+ ```