Skip to content

Commit 6e99232

Browse files
committed
Remove C++/CX
1 parent c03ce47 commit 6e99232

3 files changed

Lines changed: 3 additions & 287 deletions

File tree

hub/apps/develop/files/create-read-write-files.md

Lines changed: 1 addition & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Read and write a file using a [StorageFile](/uwp/api/windows.storage.storagefile
2929

3030
- **Understand async programming for WinUI apps**
3131

32-
You can learn how to write asynchronous apps in C# or Visual Basic, see [Call asynchronous APIs in C# or Visual Basic](/windows/uwp/threading-async/call-asynchronous-apis-in-csharp-or-visual-basic). To learn how to write asynchronous apps in C++/WinRT, see [Concurrency and asynchronous operations with C++/WinRT](/windows/uwp/cpp-and-winrt-apis/concurrency). To learn how to write asynchronous apps in C++/CX, see [Asynchronous programming in C++/CX](/windows/uwp/threading-async/asynchronous-programming-in-cpp-universal-windows-platform-apps).
32+
You can learn how to write asynchronous apps in C# or Visual Basic, see [Call asynchronous APIs in C# or Visual Basic](/windows/uwp/threading-async/call-asynchronous-apis-in-csharp-or-visual-basic). To learn how to write asynchronous apps in C++/WinRT, see [Concurrency and asynchronous operations with C++/WinRT](/windows/uwp/cpp-and-winrt-apis/concurrency).
3333

3434
- **Know how to get the file that you want to read from, write to, or both**
3535

@@ -60,12 +60,6 @@ Windows::Foundation::IAsyncAction ExampleCoroutineAsync()
6060
}
6161
```
6262

63-
```cpp
64-
// Create a sample file; replace if exists.
65-
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
66-
concurrency::create_task(storageFolder->CreateFileAsync("sample.txt", CreationCollisionOption::ReplaceExisting));
67-
```
68-
6963
```vb
7064
' Create sample file; replace if exists.
7165
Dim storageFolder As StorageFolder = Windows.Storage.ApplicationData.Current.LocalFolder
@@ -95,14 +89,6 @@ Windows::Foundation::IAsyncAction ExampleCoroutineAsync()
9589
}
9690
```
9791

98-
```cpp
99-
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
100-
create_task(storageFolder->GetFileAsync("sample.txt")).then([](StorageFile^ sampleFile)
101-
{
102-
// Process file
103-
});
104-
```
105-
10692
```vb
10793
Dim storageFolder As StorageFolder = Windows.Storage.ApplicationData.Current.LocalFolder
10894
Dim sampleFile As StorageFile = Await storageFolder.GetFileAsync("sample.txt")
@@ -129,15 +115,6 @@ Windows::Foundation::IAsyncAction ExampleCoroutineAsync()
129115
}
130116
```
131117

132-
```cpp
133-
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
134-
create_task(storageFolder->GetFileAsync("sample.txt")).then([](StorageFile^ sampleFile)
135-
{
136-
//Write text to a file
137-
create_task(FileIO::WriteTextAsync(sampleFile, "Swift as a shadow"));
138-
});
139-
```
140-
141118
```vb
142119
Await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "Swift as a shadow")
143120
```
@@ -169,15 +146,6 @@ Await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "Swift as a shadow")
169146
}
170147
```
171148

172-
```cpp
173-
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
174-
create_task(storageFolder->GetFileAsync("sample.txt")).then([](StorageFile^ sampleFile)
175-
{
176-
// Create the buffer
177-
IBuffer^ buffer = CryptographicBuffer::ConvertStringToBinary
178-
("What fools these mortals be", BinaryStringEncoding::Utf8);
179-
});
180-
```
181149

182150
```vb
183151
Dim buffer = Windows.Security.Cryptography.CryptographicBuffer.ConvertStringToBinary(
@@ -195,17 +163,6 @@ Await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "Swift as a shadow")
195163
co_await Windows::Storage::FileIO::WriteBufferAsync(sampleFile, buffer);
196164
```
197165

198-
```cpp
199-
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
200-
create_task(storageFolder->GetFileAsync("sample.txt")).then([](StorageFile^ sampleFile)
201-
{
202-
// Create the buffer
203-
IBuffer^ buffer = CryptographicBuffer::ConvertStringToBinary
204-
("What fools these mortals be", BinaryStringEncoding::Utf8);
205-
// Write bytes to a file using a buffer
206-
create_task(FileIO::WriteBufferAsync(sampleFile, buffer));
207-
});
208-
```
209166

210167
```vb
211168
Await Windows.Storage.FileIO.WriteBufferAsync(sampleFile, buffer)
@@ -233,16 +190,6 @@ Await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "Swift as a shadow")
233190
}
234191
```
235192

236-
```cpp
237-
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
238-
create_task(storageFolder->GetFileAsync("sample.txt")).then([](StorageFile^ sampleFile)
239-
{
240-
create_task(sampleFile->OpenAsync(FileAccessMode::ReadWrite)).then([sampleFile](IRandomAccessStream^ stream)
241-
{
242-
// Process stream
243-
});
244-
});
245-
```
246193

247194
```vb
248195
Dim stream = Await sampleFile.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite)
@@ -263,10 +210,6 @@ Await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "Swift as a shadow")
263210
// The code in step 3 goes here.
264211
```
265212

266-
```cpp
267-
// Add to "Process stream" in part 1
268-
IOutputStream^ outputStream = stream->GetOutputStreamAt(0);
269-
```
270213

271214
```vb
272215
Using outputStream = stream.GetOutputStreamAt(0)
@@ -289,11 +232,6 @@ Await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "Swift as a shadow")
289232
// The code in step 4 goes here.
290233
```
291234

292-
```cpp
293-
// Added after code from part 2
294-
DataWriter^ dataWriter = ref new DataWriter(outputStream);
295-
dataWriter->WriteString("DataWriter has methods to write to various types, such as DataTimeOffset.");
296-
```
297235

298236
```vb
299237
Dim dataWriter As New DataWriter(outputStream)
@@ -312,11 +250,6 @@ Await Windows.Storage.FileIO.WriteTextAsync(sampleFile, "Swift as a shadow")
312250
outputStream.FlushAsync();
313251
```
314252

315-
```cpp
316-
// Added after code from part 3
317-
dataWriter->StoreAsync();
318-
outputStream->FlushAsync();
319-
```
320253

321254
```vb
322255
Await dataWriter.StoreAsync()
@@ -344,14 +277,6 @@ auto sampleFile{ co_await storageFolder.GetFileAsync(L"sample.txt") };
344277
// Process file
345278
```
346279

347-
```cpp
348-
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
349-
create_task(storageFolder->GetFileAsync("sample.txt")).then([](StorageFile^ sampleFile)
350-
{
351-
// Process file
352-
});
353-
```
354-
355280
```vb
356281
Dim storageFolder As StorageFolder = Windows.Storage.ApplicationData.Current.LocalFolder
357282
Dim sampleFile As StorageFile = Await storageFolder.GetFileAsync("sample.txt")
@@ -374,14 +299,6 @@ Windows::Foundation::IAsyncOperation<winrt::hstring> ExampleCoroutineAsync()
374299
}
375300
```
376301

377-
```cpp
378-
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
379-
create_task(storageFolder->GetFileAsync("sample.txt")).then([](StorageFile^ sampleFile)
380-
{
381-
return FileIO::ReadTextAsync(sampleFile);
382-
});
383-
```
384-
385302
```vb
386303
Dim text As String = Await Windows.Storage.FileIO.ReadTextAsync(sampleFile)
387304
```
@@ -401,17 +318,6 @@ Dim text As String = Await Windows.Storage.FileIO.ReadTextAsync(sampleFile)
401318
// The code in step 2 goes here.
402319
```
403320

404-
```cpp
405-
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
406-
create_task(storageFolder->GetFileAsync("sample.txt")).then([](StorageFile^ sampleFile)
407-
{
408-
return FileIO::ReadBufferAsync(sampleFile);
409-
410-
}).then([](Streams::IBuffer^ buffer)
411-
{
412-
// Process buffer
413-
});
414-
```
415321

416322
```vb
417323
Dim buffer = Await Windows.Storage.FileIO.ReadBufferAsync(sampleFile)
@@ -431,11 +337,6 @@ Dim text As String = Await Windows.Storage.FileIO.ReadTextAsync(sampleFile)
431337
winrt::hstring bufferText{ dataReader.ReadString(buffer.Length()) };
432338
```
433339

434-
```cpp
435-
// Add to "Process buffer" section from part 1
436-
auto dataReader = DataReader::FromBuffer(buffer);
437-
String^ bufferText = dataReader->ReadString(buffer->Length);
438-
```
439340

440341
```vb
441342
Dim dataReader As DataReader = Windows.Storage.Streams.DataReader.FromBuffer(buffer)
@@ -457,16 +358,6 @@ Dim text As String = Await Windows.Storage.FileIO.ReadTextAsync(sampleFile)
457358
// The code in step 2 goes here.
458359
```
459360

460-
```cpp
461-
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
462-
create_task(storageFolder->GetFileAsync("sample.txt")).then([](StorageFile^ sampleFile)
463-
{
464-
create_task(sampleFile->OpenAsync(FileAccessMode::Read)).then([sampleFile](IRandomAccessStream^ stream)
465-
{
466-
// Process stream
467-
});
468-
});
469-
```
470361

471362
```vb
472363
Dim stream = Await sampleFile.OpenAsync(Windows.Storage.FileAccessMode.Read)
@@ -483,10 +374,6 @@ Dim text As String = Await Windows.Storage.FileIO.ReadTextAsync(sampleFile)
483374
// The code in step 3 goes here.
484375
```
485376

486-
```cpp
487-
// Add to "Process stream" from part 1
488-
UINT64 size = stream->Size;
489-
```
490377

491378
```vb
492379
Dim size = stream.Size
@@ -507,11 +394,6 @@ Dim text As String = Await Windows.Storage.FileIO.ReadTextAsync(sampleFile)
507394
// The code in step 4 goes here.
508395
```
509396

510-
```cpp
511-
// Add after code from part 2
512-
IInputStream^ inputStream = stream->GetInputStreamAt(0);
513-
auto dataReader = ref new DataReader(inputStream);
514-
```
515397

516398
```vb
517399
Using inputStream = stream.GetInputStreamAt(0)
@@ -534,13 +416,6 @@ Dim text As String = Await Windows.Storage.FileIO.ReadTextAsync(sampleFile)
534416
winrt::hstring streamText{ dataReader.ReadString(cBytesLoaded) };
535417
```
536418

537-
```cpp
538-
// Add after code from part 3
539-
create_task(dataReader->LoadAsync(size)).then([sampleFile, dataReader](unsigned int numBytesLoaded)
540-
{
541-
String^ streamText = dataReader->ReadString(numBytesLoaded);
542-
});
543-
```
544419

545420
```vb
546421
Dim dataReader As New DataReader(inputStream)

hub/apps/develop/files/file-access-permissions.md

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ There are two primary ways to access files and folders in your app's install dir
4343
Windows::Storage::StorageFolder installedLocation{ Windows::ApplicationModel::Package::Current().InstalledLocation() };
4444
```
4545

46-
```cpp
47-
Windows::Storage::StorageFolder^ installedLocation = Windows::ApplicationModel::Package::Current->InstalledLocation;
48-
```
4946

5047
You can then access files and folders in the directory using [StorageFolder](/uwp/api/Windows.Storage.StorageFolder) methods. In the example, this StorageFolder is stored in the `installDirectory` variable. You can learn more about working with your app package and install directory from the [App package information sample](https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/Package) on GitHub.
5148
@@ -74,13 +71,6 @@ There are two primary ways to access files and folders in your app's install dir
7471
}
7572
```
7673

77-
```cpp
78-
auto getFileTask = create_task(StorageFile::GetFileFromApplicationUriAsync(ref new Uri("ms-appx:///file.txt")));
79-
getFileTask.then([](StorageFile^ file)
80-
{
81-
// Process file
82-
});
83-
```
8474

8575
When [GetFileFromApplicationUriAsync](/uwp/api/windows.storage.storagefile.getfilefromapplicationuriasync) completes, it returns a [StorageFile](/uwp/api/Windows.Storage.StorageFile) that represents the `file.txt` file in the app's install directory (`file` in the example).
8676

@@ -115,10 +105,6 @@ There are two primary ways to access files and folders from your app's data loca
115105
};
116106
```
117107

118-
```cpp
119-
using namespace Windows::Storage;
120-
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
121-
```
122108

123109
If you want to access your app's roaming or temporary folder, use the [RoamingFolder](/uwp/api/windows.storage.applicationdata.roamingfolder) or [TemporaryFolder](/uwp/api/windows.storage.applicationdata.temporaryfolder) property instead.
124110

@@ -146,14 +132,6 @@ There are two primary ways to access files and folders from your app's data loca
146132
// Process file
147133
```
148134

149-
```cpp
150-
using Windows::Storage;
151-
auto getFileTask = create_task(StorageFile::GetFileFromApplicationUriAsync(ref new Uri("ms-appdata:///local/file.txt")));
152-
getFileTask.then([](StorageFile^ file)
153-
{
154-
// Process file
155-
});
156-
```
157135

158136
When [GetFileFromApplicationUriAsync](/uwp/api/windows.storage.storagefile.getfilefromapplicationuriasync) completes, it returns a [StorageFile](/uwp/api/Windows.Storage.StorageFile) that represents the `file.txt` file in the app's local folder (`file` in the example).
159137

@@ -200,14 +178,6 @@ By default, your app can only access files and folders in the user's Downloads f
200178
// Process file
201179
```
202180

203-
```cpp
204-
using Windows::Storage;
205-
auto createFileTask = create_task(DownloadsFolder::CreateFileAsync(L"file.txt"));
206-
createFileTask.then([](StorageFile^ newFile)
207-
{
208-
// Process file
209-
});
210-
```
211181

212182
[DownloadsFolder](/uwp/api/Windows.Storage.DownloadsFolder).[CreateFileAsync](/uwp/api/windows.storage.downloadsfolder.createfileasync) is overloaded so that you can specify what the system should do if there is already an existing file in the Downloads folder that has the same name. When these methods complete, they return a [StorageFile](/uwp/api/Windows.Storage.StorageFile) that represents the file that was created. This file is called `newFile` in the example.
213183

@@ -233,14 +203,6 @@ By default, your app can only access files and folders in the user's Downloads f
233203
// Process folder
234204
```
235205

236-
```cpp
237-
using Windows::Storage;
238-
auto createFolderTask = create_task(DownloadsFolder::CreateFolderAsync(L"New Folder"));
239-
createFolderTask.then([](StorageFolder^ newFolder)
240-
{
241-
// Process folder
242-
});
243-
```
244206

245207
[DownloadsFolder](/uwp/api/Windows.Storage.DownloadsFolder).[CreateFolderAsync](/uwp/api/windows.storage.downloadsfolder.createfolderasync) is overloaded so that you can specify what the system should do if there is already an existing subfolder in the Downloads folder that has the same name. When these methods complete, they return a [StorageFolder](/uwp/api/Windows.Storage.StorageFolder) that represents the subfolder that was created. This file is called `newFolder` in the example.
246208

0 commit comments

Comments
 (0)