Friday, April 29, 2022

C# Check if file exists after delete (issue, no solution)

 I seem to have a lot of issues managing files with C#. I have this check to make sure the file is gone after doing a delete. Manually checking, the file is gone but the app check finds the file (but does not find it after I manually check). Maybe timing issue?

fi.Delete does not always delete

Although EXE files will throw an error, there are some scenarios for non-EXE files to not throw an error. In this case, the process will continue as if the delete was executed successfully.

I have not identified why this is the case. More interestingly on the Windows end, I can "sometimes" manually delete the file with Windows explorer. Sometimes I cannot. No clue why or how or when. And when it cannot, I can rename it then delete it with Windows explorer. Why? No clue.

Delete with Process

So, I have a check if the file still exists. If it exists, I execute a command line delete: 
cmd.exe /C del [filepath]

I use Process to execute this with a WaitForExit()


Check if file still exists

Even after all this, the "fi.Exists" still returns true even when the file does not exist anymore. Does it exist when at the time of execution, I don't know. But if I debug it, it does not exist and executes the proper path. There may be some time for the process to execute??


Summary

So somehow after attempting to delete twice, the fi.exists still returns true for some reason in full execution mode but not in debug mode. Why? No clue. 

Wednesday, April 20, 2022

Error only in production "This site can’t be reached" (RCA: Very large data in textbox)

I just get a "This site can't be reached" "The connection was reset" "ERR_CONNECTION_RESET".

There can be many other reasons but hopefully this will help if all other aides did not help.

RCA

Essentially, the problem to this specific problem was the firewall has a limit on the amount data that can be transported. My textboxes contain a lot of data (in the thousands of bytes). If I remove the data in the textbox everything works in production. My local system does not have this limitation so this works in my environment.

Tuesday, April 19, 2022

Upgrading Microsoft C# SMO from 160.2004021.0 to 161.47008.0 "cannot convert from 'system.data.sqlclient.sqlconnection' to 'Microsoft.SqlServer.Management.Common.IRenewableToken'"

 ERROR:

"cannot convert from 'system.data.sqlclient.sqlconnection' to 'Microsoft.SqlServer.Management.Common.IRenewableToken'"


Convert all System.Data.SqlClient to Microsoft.Data.SqlClient


RCA

Updated Microsoft.SqlServer.SqlManagement from 160.2004021.0 to 161.47008.0