© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3mo ago•
1 reply
jolly? wickend

Creating new/rewriting temporary files in loops

otherintermediateadvanced
Long story short - Im looping this code (and some more) to write file contents to a temporary file and then perform operations on that file one after another in a loop

            using var inStream = new FileStream($"{path}", FileMode.Open, FileAccess.ReadWrite, FileShare.Read);
            using var tempStream = new FileStream(Program.soundBufferPath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
            File.SetAttributes(Program.soundBufferPath, FileAttributes.Hidden);
            using var inStream = new FileStream($"{path}", FileMode.Open, FileAccess.ReadWrite, FileShare.Read);
            using var tempStream = new FileStream(Program.soundBufferPath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
            File.SetAttributes(Program.soundBufferPath, FileAttributes.Hidden);


This is the part of the code that loops
it breaks for any reason because the access to the file is denied
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Creating Files in Visual Studio
C#CC# / help
3y ago
Creating new project in vscode
C#CC# / help
2y ago
✅ help with loops, new to c#
C#CC# / help
3y ago
Modernizing double loops in C#?
C#CC# / help
2y ago