Click here to Skip to main content
15,991,072 members
Home / Discussions / C#
   

C#

 
QuestionDataGrid - Change column Headers height and row vertical alignment text. Pin
Member 1340835626-Jul-24 7:50
Member 1340835626-Jul-24 7:50 
AnswerRe: DataGrid - Change column Headers height and row vertical alignment text. Pin
Dave Kreskowiak26-Jul-24 13:20
mveDave Kreskowiak26-Jul-24 13:20 
QuestionSqlDataReader with multiple result sets Pin
Richard Andrew x6426-Jul-24 5:07
professionalRichard Andrew x6426-Jul-24 5:07 
AnswerRe: SqlDataReader with multiple result sets Pin
Pete O'Hanlon26-Jul-24 5:32
mvePete O'Hanlon26-Jul-24 5:32 
GeneralRe: SqlDataReader with multiple result sets Pin
Richard Andrew x6426-Jul-24 5:40
professionalRichard Andrew x6426-Jul-24 5:40 
AnswerRe: SqlDataReader with multiple result sets Pin
OriginalGriff26-Jul-24 6:08
mveOriginalGriff26-Jul-24 6:08 
GeneralRe: SqlDataReader with multiple result sets Pin
Richard Andrew x6426-Jul-24 6:39
professionalRichard Andrew x6426-Jul-24 6:39 
QuestionI want to get permission to interact with a file. Pin
Yohan Bischofberger25-Jul-24 9:15
Yohan Bischofberger25-Jul-24 9:15 
Hello,

I want to work with a File. I cant get Permission or owner.
Im not the owner of the files as i can see in the propertys.
The Path of the Files are: %userprofile%\AppData\Local\Temp

Here is how i tried to get access owner or permission:

//Create FileInfo

FileInfo info = new FileInfo(path);

//Create FileSecurity

FileSecurity security = FileSystemAclExtensions.GetAccessControl(info);

//Create Privileges

SecurityIdentifier identifier = WindowsIdentity.GetCurrent().User;

//Set Owner

security.SetOwner(identifier);

//Set Access rules

security.AddAccessRule(new FileSystemAccessRule(identifier, FileSystemRights.FullControl, AccessControlType.Allow));

//Update Acces Controll on File

FileSystemAclExtensions.SetAccessControl(info, security);



My goal is to open a FileStream and Write over the File, here is a exaple:

File.SetAttributes(_recycleBin, FileAttributes.Normal);
string[] files = Directory.GetFiles(_recycleBin, "", System.IO.SearchOption.AllDirectories);

foreach (string file in files)
{
    try
    {
        // Set the files attributes to normal in case it's read-only.

        File.SetAttributes(file, FileAttributes.Normal);

        // Calculate the total number of sectors in the file.
        double sectors = Math.Ceiling(new FileInfo(file).Length / 512.0);

        // Create a dummy-buffer the size of a sector.

        byte[] dummyBuffer = new byte[512];

        // Create a cryptographic Random Number Generator.
        // This is what I use to create the garbage data.

        RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();

        Trace.WriteLine("DEBUG LOG: " + file + "loaded.");

        FileStream inputStream = new FileStream(file, FileMode.Open);

        for (int currentPass = 0; currentPass < timesToWrite; currentPass++)
        {
            //UpdatePassInfo(currentPass + 1, timesToWrite);

            // Go to the beginning of the stream

            inputStream.Position = 0;

            // Loop all sectors
            for (int sectorsWritten = 0; sectorsWritten < sectors; sectorsWritten++)
            {
                //UpdateSectorInfo(sectorsWritten + 1, (int)sectors);

                // Fill the dummy-buffer with random data

                rng.GetBytes(dummyBuffer);

                // Write it to the stream
                inputStream.Write(dummyBuffer, 0, dummyBuffer.Length);
            }

            //Deletes the File and closes the Filestream in last pass

            if (currentPass == timesToWrite - 1)
            {
                inputStream.Close();
                FileSystem.DeleteFile(file);
            }
        }
    }
    catch
    {

    }
}

QuestionRe: I want to get permission to interact with a file. Pin
Richard MacCutchan25-Jul-24 10:24
mveRichard MacCutchan25-Jul-24 10:24 
QuestionC# Trying to Create Custom Spell Checking Feature but keep running into roadblocks. Argument 1: cannot convert from 'System.IO.MemoryStream' to 'string' Argument 2: cannot convert from 'System.Drawing.Imaging.ImageFormat' to 'Tesseract.ImageFormat?' Pin
Texas-Tundra24-Jul-24 6:46
Texas-Tundra24-Jul-24 6:46 
AnswerRe: C# Trying to Create Custom Spell Checking Feature but keep running into roadblocks. Argument 1: cannot convert from 'System.IO.MemoryStream' to 'string' Argument 2: cannot convert from 'System.Drawing.Imaging.ImageFormat' to 'Tesseract.ImageForma Pin
OriginalGriff24-Jul-24 18:58
mveOriginalGriff24-Jul-24 18:58 
GeneralRe: C# Trying to Create Custom Spell Checking Feature but keep running into roadblocks. Argument 1: cannot convert from 'System.IO.MemoryStream' to 'string' Argument 2: cannot convert from 'System.Drawing.Imaging.ImageFormat' to 'Tesseract.ImageForma Pin
Texas-Tundra25-Jul-24 2:08
Texas-Tundra25-Jul-24 2:08 
GeneralRe: C# Trying to Create Custom Spell Checking Feature but keep running into roadblocks. Argument 1: cannot convert from 'System.IO.MemoryStream' to 'string' Argument 2: cannot convert from 'System.Drawing.Imaging.ImageFormat' to 'Tesseract.ImageForma Pin
OriginalGriff25-Jul-24 2:39
mveOriginalGriff25-Jul-24 2:39 
GeneralRe: C# Trying to Create Custom Spell Checking Feature but keep running into roadblocks. Argument 1: cannot convert from 'System.IO.MemoryStream' to 'string' Argument 2: cannot convert from 'System.Drawing.Imaging.ImageFormat' to 'Tesseract.ImageForma Pin
Texas-Tundra25-Jul-24 2:45
Texas-Tundra25-Jul-24 2:45 
GeneralRe: C# Trying to Create Custom Spell Checking Feature but keep ... Pin
OriginalGriff25-Jul-24 2:50
mveOriginalGriff25-Jul-24 2:50 
QuestionDPI issue when calling C# from C++ Pin
JudyL_MD23-Jul-24 11:05
JudyL_MD23-Jul-24 11:05 
AnswerRe: DPI issue when calling C# from C++ Pin
Richard Andrew x6423-Jul-24 12:08
professionalRichard Andrew x6423-Jul-24 12:08 
GeneralRe: DPI issue when calling C# from C++ Pin
JudyL_MD23-Jul-24 17:26
JudyL_MD23-Jul-24 17:26 
QuestionLog file advice? Pin
geomeo12318-Jul-24 15:12
geomeo12318-Jul-24 15:12 
AnswerRe: Log file advice? Pin
jschell19-Jul-24 13:24
jschell19-Jul-24 13:24 
GeneralRe: Log file advice? Pin
Richard Andrew x6420-Jul-24 14:37
professionalRichard Andrew x6420-Jul-24 14:37 
GeneralRe: Log file advice? Pin
geomeo12324-Jul-24 3:38
geomeo12324-Jul-24 3:38 
GeneralRe: Log file advice? Pin
jschell24-Jul-24 14:48
jschell24-Jul-24 14:48 
AnswerRe: Log file advice? Pin
Richard MacCutchan24-Jul-24 5:13
mveRichard MacCutchan24-Jul-24 5:13 
GeneralRe: Log file advice? Pin
Rob Philpott24-Jul-24 22:44
Rob Philpott24-Jul-24 22:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.