Remove readonly attribute from directory
var di = new DirectoryInfo(“SomeFolder”); di.Attributes &= ~FileAttributes.ReadOnly;
var di = new DirectoryInfo(“SomeFolder”); di.Attributes &= ~FileAttributes.ReadOnly;
Thank you for you suggestion Panoptik, adding readonly on focusin, and then removing it on focusout was the cleanest way, million thanks! I answer myself in case anyone has the same problem. Hope it helps. $(document).on(“focusin”, “#someid”, function() { $(this).prop(‘readonly’, true); }); $(document).on(“focusout”, “#someid”, function() { $(this).prop(‘readonly’, false); });
Tuples originated in functional programming. In (purely) functional programming, everything is immutable by design – a certain variable only has a single definition at all times, as in mathematics. The .NET designers wisely followed the same principle when integrating the functional style into C#/.NET, despite it ultimately being a primarily imperative (hybrid?) language. Note: Though … Read more
That error message is typically seen when using the Spring OpenSessionInViewFilter and trying to do persistence operations outside of a Spring-managed transaction. The filter sets the session to FlushMode.NEVER/MANUAL (depending on the versions of Spring and Hibernate you’re using–they’re roughly equivalent). When the Spring transaction mechanism begins a transaction, it changes the flush mode to … Read more
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
The first one is a read-only field, while the second one gets compiled as a pair of methods (and all reads of the property ProductLocation gets compiled into calls to the corresponding get method and writes to it gets compiled into calls to the set method; internally, these methods will read from / write to … Read more
In addition to connecting with a read-only user, there are a few other things you can do to your DbContext. public class MyReadOnlyContext : DbContext { // Use ReadOnlyConnectionString from App/Web.config public MyContext() : base(“Name=ReadOnlyConnectionString”) { } // Don’t expose Add(), Remove(), etc. public DbQuery<Customer> Customers { get { // Don’t track changes to query … Read more
You could write your own read-only wrapper for the dictionary, e.g.: public class ReadOnlyDictionaryWrapper<TKey, TValue, TReadOnlyValue> : IReadOnlyDictionary<TKey, TReadOnlyValue> where TValue : TReadOnlyValue { private IDictionary<TKey, TValue> _dictionary; public ReadOnlyDictionaryWrapper(IDictionary<TKey, TValue> dictionary) { if (dictionary == null) throw new ArgumentNullException(“dictionary”); _dictionary = dictionary; } public bool ContainsKey(TKey key) { return _dictionary.ContainsKey(key); } public IEnumerable<TKey> Keys … Read more
I think it’s a poor judgement on part of C# architects. readonly modifier on local variables helps maintain program correctness (just like asserts) and can potentially help the compiler optimize code (at least in the case of other languages). The fact that it’s disallowed in C# right now, is another argument that some of the … Read more
You can make a numpy array unwriteable: a = np.arange(10) a.flags.writeable = False a[0] = 1 # Gives: ValueError: assignment destination is read-only Also see the discussion in this thread: http://mail.scipy.org/pipermail/numpy-discussion/2008-December/039274.html and the documentation: http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.flags.html