Tuesday, March 22, 2022

C# Copy File But Error because it is being used by another process

Error: because it is being used by another process.

I get this error when using File.Copy(fileSource, fileTarget, true);

Not exactly the solution from stackoverflow, but this is the solution that I used:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
try
{
    File.Copy(fileSource, fileTarget, true);
}
catch (IOException e)
{
    if (e.Message.Contains("in use"))
    {

        Process p = new Process();
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardOutput = true;
        p.StartInfo.FileName = "cmd.exe";
        p.StartInfo.Arguments = "/C copy \"" + fileSource + "\" \"" + fileTarget + "\"";
        p.Start();
        Console.WriteLine(p.StandardOutput.ReadToEnd());
        p.WaitForExit();
        p.Close();
    }
}

I don't know why this works though. Before I had to go to the physical server, rename the file, then copy. I still do not know why the files are locked. Nothing should be running it. This is not a problem with all applications running on the server.


Reference

https://stackoverflow.com/questions/6167136/how-to-copy-a-file-while-it-is-being-used-by-another-process

Monday, March 21, 2022

Work Life: Problems with Documenting

Everywhere I worked, everyone always complain about documentation. Yet, no one has ever maintained documentation. This is over a span of 20 years and 8 companies. Since my third job, I have always documented and encouraged documentation. Here I am thinking back to all my experiences on why I have essentially failed in promoting this eco-system.

Each career move has allowed me to somewhat restart and improve on my processes. Essentially since the initial attempt, I have always attempted to centralize and share via the shared document. This eventually turned towards Atlassian Confluence as my preferential choice as it has been available at large to corporate-sized employers. Prior to this was a shared drive or Microsoft SharePoint. If I had to share information that I thought would be re-used, I created an artifact, stored it, then pointed the requestor to that artifact.

Everyone loved it and found it useful. But no one has ever adopted it. If I had time, I would also include answers to my questions then respond back with a link for their future use. I am also of curious mind so I also learn more to understand what other groups do or working on. I also listen in on calls and document if I am not an active participant. None of these ever improved even if all my managers "loved" the work that I did. They would suggest to others but never enforced it. I would get praises during townhalls (I hate these sections in townhalls) and my raises and bonuses would always include this as part of my excellence.

But I don't do it for praise. I just want to solve a corporate problem that "seems" to be beneficial for everyone, wins for everyone, and something that seems to be universally seen as a problem. So why am I not able to "solve" the problem?

Change is Hard?

This is almost an obstacle for anything in a company. It is too generic, also never was a satisfying answer to any changes. Let's say the change is to increase everyone's salary, then everyone will find a way to change even in ways that are not expected. To me there is some level of incentives but obviously this is not met with documentation.

Is the problem that "I" do the work for "some else" to have an easier job that I used to struggle with? Are people jealous that others have an advantage over their "potential" replacements? I suppose this is a legitimate reason. To me the view should be that this their chance to leave the position to do something greater because if we all keep learning, replacements will never really keep up. Does this mean that people are "lazy" of continual learning? Are there more lazy learners who fear their own job security?

I think that is the most likely scenario. If money typically drive people and raises/promotions get more money, why is this a problem? I think the most likely case here is that their is poor sets of expectations for promotions or corrupted sets of values.

Incentives?

I think in the past, I have thought incorrectly about incentives. One of my problems I saw with promotions was that managers were never able to release their old work. I have thought that documentation would have helped in these situations.

But as I work with more and more people, I feel generally people fear the most is job security. The second with promotions is self-image. What works for most people is consolidating information to yourself.

The reason for this is because by hoarding information, the person is artificially increasing its own asset value to the company. If the person leaves, then that set of information is also gone. If documentation exists, then it is easier to release the person. This I have seen at most of the companies I have worked for. There is always a "star" employee that everyone goes to for information. What is also kind of amazing is that this "star" employee is always a major jerk to junior people (some are unbiased to seniority). Usually with 20+ years of specific experience to that department.

First, the culture appears to incentivize info hoarding as they keep praising this person. Also you need to be an "ass" about hoarding the information: don't join calls, don't respond to emails, don't respond to messages... unless it has been escalating 2-3 levels. Even directors are afraid of upsetting these employees.

This makes sense to me now because besides that information, I would not keep these people. I also sensed these people tend to no like me much because I typically found a way to get the information I needed. At this point in my career, I was also decently versed on protecting myself from petty games where they try to throw me under the bus. One of the most common way was that I didn't ask or set up a meeting except that I make sure that I always send an email or something that is recorded to show that I have done what they claim I did not do. Usually after one or two times that I stand up for myself, they will stop but I see them do it to others.

Is it guaranteed that there is one of these people exists in large groups? I think this exists because most of these successful groups do start off small which could not hire more talented people. More talented people can readily replace less talented. This may be the only method for an original employee to stay relevant. 

Self-preservation

I think I am starting to sense that my endeavor to change corporate culture that has existed for multiple decades are nearly impossible if the original employees are still in the group. It does seem that groups with high overall turnover seems to adopt a bit better.

So intentionally or not, it seems most people naturally do not document but wishes others do so. In all my experiences, everyone who stays seem to be those that have all the internal knowledge of the system. They are also all very attached to the "old" ways most likely because new things make their their knowledge more likely to be obsolete.

Monday, March 14, 2022

Notes: MariaDb Sequence

1. Create a sequence

CREATE SEQUENCE [Name of Sequence]


2. Get next sequence id

nextval([Name of Sequence])



Reference

https://mariadb.com/kb/en/create-sequence/

Thursday, March 10, 2022

What would you do? QA lead is out. No process to handle backlog. As SM...

SM = Scrum Master

Sometimes it is just so frustrating dealing with people. Am I not understanding their question or their problem? Do they just not understand what other people is supposed to know or do? Are they just clueless or am I clueless?

Scenario

The QA lead has been out and will be out for the rest of the week. I brought up that I have been completing my tasks. These tasks when completed go to the QA lead. In the call, I just bring to attention that there will likely be a large backlog of items for QA team to do and if their is some process to check on the list while the lead is unavailable.

Not surprisingly, there is no processes for this situation. So it was tasked to our new Scrum Master to look into the situation. The SM is responsible of making sure changes are moving along.

You have two QA testers who have their usual work and backlog. QA lead used to assign tasks to them. How this is done is not known. I add about 5-10 changes to their backlog per day. When looking into the backlog there are over 50 changes pending. Some are four months old. It is Thursday, and QA lead will return on Monday.

What would you do?

Time Limit to Think = 1 hr
Time to Explain = 5 minutes

As the scrum master, what would you do?