How do I open an already opened file with a .net StreamReader?

As Jared says, You cannot do this unless the other entity which has the file open allows for shared reads. Excel allows shared reads, even for files it has open for writing. Therefore, you must open the filestream with the FileShare.ReadWrite parameter. The FileShare param is often misunderstood. It indicates what other openers of the … Read more

how can I disable everything inside a form using javascript/jquery?

This is quite simple in plain JavaScript and will work efficiently in all browsers that support read-only form inputs (which is pretty much all browsers released in the last decade): var form = document.getElementById(“your_form_id”); var elements = form.elements; for (var i = 0, len = elements.length; i < len; ++i) { elements[i].readOnly = true; }

How to make a input field readonly with JavaScript?

You can get the input element and then set its readOnly property to true as follows: document.getElementById(‘InputFieldID’).readOnly = true; Specifically, this is what you want: <script type=”text/javascript”> function onLoadBody() { document.getElementById(‘control_EMAIL’).readOnly = true; } </script> Call this onLoadBody() function on body tag like: <body onload=”onLoadBody”> View Demo: jsfiddle.

How do I delete a directory with read-only files in C#?

Simplest way of avoiding recursive calls is by utilising the AllDirectories option when getting FileSystemInfos, like so: public static void ForceDeleteDirectory(string path) { var directory = new DirectoryInfo(path) { Attributes = FileAttributes.Normal }; foreach (var info in directory.GetFileSystemInfos(“*”, SearchOption.AllDirectories)) { info.Attributes = FileAttributes.Normal; } directory.Delete(true); }

WCF: Exposing readonly DataMember properties without set?

Your “server-side” class won’t be “made available” to the client, really. What happens is this: based on the data contract, the client will create a new separate class from the XML schema of the service. It cannot use the server-side class per se! It will re-create a new class from the XML schema definition, but … Read more

Is read-only auto-implemented property possible?

The answer below was written back in 2010. In C# 6 (released in 2015) you can write read-only automatically-implemented properties: // This can only be assigned to in a constructor public int Foo { get; } You’re absolutely right. Properly read-only automatically implemented properties are currently impossible. Making the setter private isn’t the same thing, … Read more

How to make a git repository read-only?

There is more than one possible way to do this. If your users each have a shell account (perhaps limited), and each of them accessing git repositories via their own account, you can use filesystem permissions to control SSH access to git repositories. On Unix those would be write permissions on directories, perhaps with the … Read more

What’s the best way of creating a readonly array in C#?

Use ReadOnlyCollection<T>. It is read-only and, contrary to what you believe, it has an indexer. Arrays are not immutable and there is no way of making them so without using a wrapper like ReadOnlyCollection<T>. Note that creating a ReadOnlyCollection<T> wrapper is an O(1) operation, and does not incur any performance cost. Update Other answers have … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)