Thursday, October 29, 2015

Share folder Permissions - Just basic stuff

Once the folder is shared on network, all previous permissions need to be revised on the folder. The admin of machine where the folder is shared from doesn't even have permission once the folder is shared.

So 2 things need to be set under Sharing and Security tabs of folder.
Right click on folder and you see both these folders:

Sharing tab: Click on Share button. A window will open. Add the user and then on right column give necessary permissions to this newly added user.

Security tab: Click on Edit button. A window will open. Add the user and then on bottom pane, give necessary permissions to this newly added user.

There are many other things you can control hierarchical wise which you welcome to search on your own.


HTH.

Wednesday, October 28, 2015

How to get distinct records from array?

Using linq, it's pretty easy to get distinct records from array.
Lets say you have file filled with record and you read the file into array.
Now on this array, you can use lambda/linq expression to filter the list.
The code will keep the first record it found and throws all duplicates after it found the first one.

For my work, it was matter because I need to process in the order
they receive.


' Read complete file.
Dim lines() As String = File.ReadAllLines("C\dummyrecord.txt")


' group array items and get the first record.
Dim distinctList = lines.GroupBy(Function(x) x.ToString).Select(Function(grp) grp.First).ToArray


That's it!!


This line will return an String Array as well. Depending on your choice, you can also get
different data structures instead of array.


Linq Explanation:

2 functions are used: GroupBy and Select. Both take function as an argument which let you reference the items of object (array/list).
GroupBy will take function as argument using which you can reference elements of array/object.
Then you using Select method, you reference the grouped items and get the first record of many duplicate records.


HTH!