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

質問編集履歴

2

回答者様より依頼のあった、変更後のコードを追記+文字数オーバーの為、環境部分を削除しました

2020/04/03 00:49

投稿

as00000
as00000

スコア21

title CHANGED
File without changes
body CHANGED
@@ -11,8 +11,8 @@
11
11
 
12
12
  ご教示をお願いします
13
13
 
14
-
14
+ ---
15
- ※4/1追記
15
+ ###### ※4/1追記
16
16
  ``` C#
17
17
  DirectoryInfo directoryInfo = new DirectoryInfo(targetFolderPath);
18
18
 
@@ -30,8 +30,96 @@
30
30
  このエラーのせいでFalseが返って来ているのだと思いますが
31
31
  エラーの原因が分かりません
32
32
 
33
+ ---
33
34
 
35
+ ###### ※4/3追記
36
+ [f-miyu](https://teratail.com/users/f-miyu#reply)さんに依頼頂いたので
37
+ 変更後の Package.appxmanifest と UWP側で書いたコードを追記します
34
38
 
39
+ ```xml
40
+ <?xml version="1.0" encoding="utf-8"?>
41
+
42
+ <!--<Package
43
+ xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
44
+ xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
45
+ xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
46
+ IgnorableNamespaces="uap mp">-->
47
+
48
+ <Package
49
+ xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
50
+ xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
51
+ xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
52
+ xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
53
+ IgnorableNamespaces="uap mp rescap">
54
+
55
+ ...
56
+
57
+ <!--<Capabilities>
58
+ <Capability Name="internetClient" />
59
+ </Capabilities>-->
60
+
61
+ <Capabilities>
62
+ <rescap:Capability Name="broadFileSystemAccess" />
63
+ </Capabilities>
64
+
65
+ </Package>
66
+ ```
67
+
68
+ ↓とりあえず動作確認の為に、項目の少ないインターフェースを作成しました
69
+ ```C#
70
+
71
+ [assembly: Dependency(typeof(DataOperatorUWP))]
72
+ namespace PlaceTheProcessingData.UWP
73
+ {
74
+ class DataOperatorUWP : IDataOperator
75
+ {
76
+ public async Task<TargetFiles> GetAllSourceDataAsync(DirectoryPath sourcePath)
77
+ {
78
+ // 『sourcePath.Main = public List<string> GetSourceFiles(string targetFolderPath)に
79
+ // 渡していた targetFolderPathです』
80
+ var folder = await StorageFolder.GetFolderFromPathAsync(sourcePath.Main); //←【ここから進みません】
81
+ var files = await folder.GetFilesAsync();
82
+
83
+ return new TargetFiles();
84
+
85
+ }
86
+
87
+ public TargetFiles GetSpecificedCodeData(string projectCode, DirectoryPath sourcePath)
88
+ {
89
+ throw new NotImplementedException();
90
+ }
91
+ }
92
+ }
93
+
94
+ ```
95
+ ↓インターフェースの定義
96
+ ```C#
97
+ public interface IDataOperator
98
+ {
99
+
100
+ Task<TargetFiles> GetAllSourceDataAsync(DirectoryPath sourcePath);
101
+ TargetFiles GetSpecificedCodeData(string projectCode, DirectoryPath sourcePath);
102
+
103
+ }
104
+ ```
105
+
106
+ ↓実際にUWP側を呼び出している部分
107
+ ```C#
108
+ public void GetFileInfo()
109
+ {
110
+
111
+ var dataOperator = DependencyService.Get<IDataOperator>();
112
+ this.SourceAllData = dataOperator.GetAllSourceDataAsync(this.SourcePath).Result;
113
+
114
+ this.SourceAllData = this.dataOperator.GetAllSourceData(this.SourcePath);
115
+ this.SourceSpecificedCodeData = this.dataOperator.GetSpecificedCodeData(this.Code, this.SourcePath);
116
+ this.DestinationSpecificedCodeData = this.dataOperator.GetSpecificedCodeData(this.Code, this.DestinationPath);
117
+ this.SaveSpecificedCodeData = this.dataOperator.GetSpecificedCodeSaveFolders(this.Code, this.SavePath);
118
+
119
+ ```
120
+
121
+ ---
122
+
35
123
  ### 該当のソースコード
36
124
  `Testからメソッドを呼び出している部分(希望通りTrueになるパターン)`
37
125
  ```C#
@@ -188,111 +276,68 @@
188
276
  Microsoft Visual C++ 2019
189
277
 
190
278
  ASP.NET and Web Tools 2019 16.4.460.23317
191
- ASP.NET and Web Tools 2019
192
279
 
193
280
  ASP.NET Web Frameworks and Tools 2019 16.4.460.23317
194
- 詳細については、https://www.asp.net/ をご覧ください
195
281
 
196
282
  Azure App Service Tools v3.0.0 16.4.460.23317
197
- Azure App Service Tools v3.0.0
198
283
 
199
284
  Azure Functions and Web Jobs Tools 16.4.460.23317
200
- Azure Functions and Web Jobs Tools
201
285
 
202
286
  C# ツール 3.4.1-beta4-19614-01+165046097562cfe65b09c2e9a9d8f7cd88526f2c
203
- IDE で使用する C# コンポーネント。プロジェクトの種類や設定に応じて、異なるバージョンのコンパイラを使用できます。
204
287
 
205
- CaseConverter 2.3
206
- This is a simple visual studio extension to convert text between snake_case, camelCase and PascalCase.
207
-
208
288
  Common Azure Tools 1.10
209
- Azure Mobile Services および Microsoft Azure Tools で使用する共通サービスを提供します。
210
289
 
211
290
  Extensibility Message Bus 1.2.0 (d16-2@8b56e20)
212
- Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.
213
291
 
214
292
  F# 4.6 用 Visual F# Tools 10.4 16.4.0-beta.19556.5+e7597deb7042710a7142bdccabd6f92b0840d354
215
- F# 4.6 用 Microsoft Visual F# Tools 10.4
216
293
 
217
- FormatDocumentOnSave 1.0
218
- Enables auto formatting of the code when you save a file. Visual Studio supports auto formatting of the code with the CTRL+E,D or CTRL+E,F key shortcuts but with this extension the command 'Format Document' is executed on Save.
219
-
220
- You can find the source here: https://github.com/Elders/VSE-FormatDocumentOnSave
221
-
222
- IntelliCode 拡張機能 1.0
223
- IntelliCode Visual Studio 拡張機能の詳細情報
224
-
225
294
  Microsoft Azure Tools 2.9
226
- Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.21016.1
227
295
 
228
296
  Microsoft Continuous Delivery Tools for Visual Studio 0.4
229
- Visual Studio IDE 内からの Azure DevOps パイプラインの構成を簡略化しています。
230
297
 
231
298
  Microsoft JVM Debugger 1.0
232
- Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
233
299
 
234
300
  Microsoft MI-Based Debugger 1.0
235
- Provides support for connecting Visual Studio to MI compatible debuggers
236
301
 
237
302
  Microsoft Visual C++ ウィザード 1.0
238
- Microsoft Visual C++ ウィザード
239
303
 
240
304
  Microsoft Visual Studio Tools for Containers 1.1
241
- ターゲット環境で ASP.NET Core アプリケーションを開発、実行、検証します。F5 キーを押してコンテナーで直接アプリケーションをデバッグ実行するか、Ctrl + F5 キーを押してコンテナーをリビルドせずにアプリを編集して更新します。
242
305
 
243
306
  Microsoft Visual Studio VC パッケージ 1.0
244
- Microsoft Visual Studio VC パッケージ
245
307
 
246
308
  Mono Debugging for Visual Studio 16.5.24 (1fafd7e)
247
- Support for debugging Mono processes with Visual Studio.
248
309
 
249
310
  NuGet パッケージ マネージャー 5.4.0
250
- Visual Studio 内の NuGet パッケージ マネージャー。NuGet の詳細については、https://docs.nuget.org/ にアクセスしてください
251
311
 
252
312
  PHP Tools for Visual Studio 1.32.11706.2019
253
- PHP Tools extend Visual Studio with a set of features to build PHP applications more efficiently. It makes code more readable, easier to navigate, and clean.
254
313
 
255
314
  ProjectServicesPackage Extension 1.0
256
- ProjectServicesPackage Visual Studio Extension Detailed Info
257
315
 
258
316
  SQL Server Data Tools 16.0.62002.03150
259
- Microsoft SQL Server Data Tools
260
317
 
261
318
  StylerPackage Extension 1.0
262
- StylerPackage Visual Stuido Extension Detailed Info
263
319
 
264
320
  TypeScript Tools 16.0.11031.2001
265
- TypeScript Tools for Microsoft Visual Studio
266
321
 
267
322
  Visual Basic ツール 3.4.1-beta4-19614-01+165046097562cfe65b09c2e9a9d8f7cd88526f2c
268
- IDE で使用する Visual Basic コンポーネント。プロジェクトの種類や設定に応じて、異なるバージョンのコンパイラを使用できます。
269
323
 
270
324
  Visual Studio Code デバッグ アダプターのホスト パッケージ 1.0
271
- Visual Studio Code デバッグ アダプターを Visual Studio でホストするための相互運用レイヤー
272
325
 
273
326
  Visual Studio Tools for Containers 1.0
274
- Visual Studio Tools for Containers
275
327
 
276
328
  Visual Studio コンテナー ツール拡張機能 (プレビュー) 1.0
277
- Visual Studio 内のコンテナーを表示、管理、診断します。
278
329
 
279
330
  VisualStudio.DeviceLog 1.0
280
- パッケージに関する情報
281
331
 
282
332
  VisualStudio.Foo 1.0
283
- Information about my package
284
333
 
285
334
  VisualStudio.Mac 1.0
286
- Mac Extension for Visual Studio
287
335
 
288
336
  Xamarin 16.4.000.311 (d16-4@ddfd842)
289
- Xamarin.iOS と Xamarin.Android の開発を有効にする Visual Studio 拡張機能
290
337
 
291
338
  Xamarin Designer 16.4.0.475 (remotes/origin/d16-4@ac250f5aa)
292
- Visual Studio で Xamarin Designer ツールを有効にするための Visual Studio 拡張機能。
293
339
 
294
340
  Xamarin Templates 16.4.25 (579ee62)
295
- Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
296
341
 
297
342
  Xamarin.Android SDK 10.1.4.0 (d16-4/e44d1ae)
298
343
  Xamarin.Android Reference Assemblies and MSBuild support.
@@ -302,6 +347,4 @@
302
347
  SQLite: xamarin/sqlite/3.28.0@46204c4
303
348
  Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-5@9f4ed4b
304
349
 
305
-
306
- Xamarin.iOS and Xamarin.Mac SDK 13.10.0.17 (5f802ef)
350
+ Xamarin.iOS and Xamarin.Mac SDK 13.10.0.17 (5f802ef)
307
- Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

1

追加で判明した事があるので、追記しました

2020/04/03 00:49

投稿

as00000
as00000

スコア21

title CHANGED
@@ -1,1 +1,1 @@
1
- Xamarin C# で Directory.Existsのり値が変わってしまいます
1
+ Xamarin C# で Directory.Existsのり値が変わってしまいます
body CHANGED
@@ -9,8 +9,29 @@
9
9
  何故、この様な挙動になるのか
10
10
  同じ結果が返る様にするには、どこを直せば良いのかが全く分かりません
11
11
 
12
- ご教をお願いします
12
+ ご教をお願いします
13
13
 
14
+
15
+ ※4/1追記
16
+ ``` C#
17
+ DirectoryInfo directoryInfo = new DirectoryInfo(targetFolderPath);
18
+
19
+ if (Directory.Exists(targetFolderPath))
20
+                   ~
21
+ ```
22
+ Directory.Existsの前でDirectoryInfoを確認してみた所
23
+ ![イメージ説明](d13eb43bc6eaa431b7214d29b3351685.png)
24
+ 'System.UnauthorizedAccessException' の例外が出ていました
25
+ (フォルダ名は事情により少し変えていますが、フォルダは間違いなく存在します)
26
+
27
+ Windowsは管理者権限で立ち上げていますし、VisualStudioを管理者権限で起動しても
28
+ 結果は変わりませんでした
29
+
30
+ このエラーのせいでFalseが返って来ているのだと思いますが
31
+ エラーの原因が分かりません
32
+
33
+
34
+
14
35
  ### 該当のソースコード
15
36
  `Testからメソッドを呼び出している部分(希望通りTrueになるパターン)`
16
37
  ```C#