Friday, 23 October 2015

Working with FileObject in JavaScript

Normally, we do follow all file operation at Server Level.

Sometimes, we got requirement from Clients to save file at local machine, create folder at Specific path, delete temporary file or folder, etc..

We can use FileSystem Object which is provided by IE.
It will work in Internet Explorer Only. 

We can not use the same feature for other browsers as they do not provide FileSystem Object.

There are number of methods that we can use for File Operations.

1. CreateFolder()
        Syntax: filesystemobject.CreateFolder(name)

        This method used to create a new folder at client machine. use the following code snippet to implement the same for your application.

<html>
    <body>
     <script language="JScript">
     <!--
      function create()
      {
           var myObject, newfolder;
          myObject = new ActiveXObject("Scripting.FileSystemObject");
          newfolder = myObject.CreateFolder ("c:\\newtmp\\");
      }
     -->
     </script>
 <form name="myForm">
        <input type="Button" value="Click to Create New Folder" onClick='create()'>
 </form>
    </body>
</html>


2. CreateTextFile()

Sometimes, we need to store some data which we need to use for further operation, at that time, we create a local file at client location. for that CreateTextFile is useful which helps to create a file at client machine.

    Syntax: filesystemobject.CreateTextFile(filename, overwrite)

Overwrite is a boolean value which indicates whether you want to overwrite the existing file.
use the following snippet example for more clarification.


<html>
    <body>
     <script language="JScript">
     <!--
      function createFile()
      {
          var myObject, newfile;
          myObject = new ActiveXObject("Scripting.FileSystemObject");
          newfile = myObject.CreateTextFile("c:\\testing.txt", false);
      }
     -->
     </script>
    
     <form name="myForm">
    <input type="Button" value="Click to Create New File" onClick='createFile()'>
 </form>
    </body>
</html>

The same way there are many methods which is used for file operation at client side.
for more details please visit: More Methods

3. BuildPath()
4. CopyFile()
5. CopyFolder()
6. DeleteFile()
7. DeleteFolder()
8. DriveExists()
9. GetAbsolutePathName()
10. GetBaseName()
11. GetDrive()
12. Drives()
13. FileExists()
14. FolderExists()
15. GetDriveName()
16. GetExtensionName()
17. GetFile()
18. GetFileName()
19. GetFolder()
20. GetParentFolderName()
21. GetSpecialFolder()
22. MoveFile()
23. MoveFolder()
24. OpentextFile()

Wednesday, 21 October 2015

Create Library folder using C# in windows 7 or later versions


Library Sample

As you all aware that, In windows 7 Microsoft has launched Library feature in operating system. as you can see it in below image, library is visible in left pan in explorer window.


This is neither a shortcut nor folder. It is a different API.

In some ways, a library is similar to a folder. For example, when you open a library, you'll see one or more files. However, unlike a folder, a library gathers files that are stored in several locations. 

It does not store any data. It monitors folders that contain your items, and let you access and arrange the items in different ways.

you can see the feature of library from msdn

To implement the same using C# programming language, we need to use Shell API provided by microsoft as well as APICodePack.

You'll found many post which is available in C++.

After my long research and PoC, I have found an easy way to impletement the same. you can follow guidelines from here Include Library & working with Windows Library

Please follow the steps to Create a small program which may be useful for your application. 

1. Create a console application & give it a suitable name i.e. CreateLibrary.


Create Project


2. Open Package Manager Console and add reference from Nuget.

you can view reference detail from nuget. OR simply run the below command.
Install-Package WindowsAPICodePack-Shell

It will add required Shell DLL in project solution. if you check in your reference folder, two DLLs will be added.

  1. Microsoft.WindowsAPICodePack 
  2. Microsoft.WindowsAPICodePack.Shell
3. add Namespace in Program.cs file.
        
        using Microsoft.WindowsAPICodePack.Shell;

Namespace

4. Create one method to create library using ShellLibrary class as shown below.

       
        public static bool CreateLibrary()
        {
            try
            {
                ShellLibrary lib = new ShellLibrary("Sample", true); 
                //[you can give a different name of library which is suitable for your requirement ]
                //[true flag mentions that overwrite library if exist, and there is no issue of                               // overwriting it as it is just a pointer to folder]
                string path = "D:\\";  
                //[Path that you want to refer]
                lib.Add(path);
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
Code Snipet

5. Call this method from main() function.

function call



6. Run the program. you can see the Library is created in Libraries in left pan.
New Library added



The same way you can choose your folder which you need to point in Library, give an appropriate name of Library. and use the code snippet in your program need.

You can use this as a referenceDLL, in Window Application as well as API calls.

Please note that this DLL is not signed - does not provided by Author. so you can not create signed DLL. so you can not use the same in ActiveX if you are planning to use it. Because ActiveX requires Signed DLL only.

Thanks.

For any queries please drop a message.

Tuesday, 21 April 2015

I'm Back !!

Hell yeah !!!

It's been long time I was away from this blog.
Now, It's time to recollect all the knowledge and start putting it down here.

So, I'd like to share what happened in this last 3 years... :)

well, nothing special. As usual Life.

I have traveled a lot in past year 2014. It was wonderful time with new and old friends, colleagues and all.

The good thing, Minesweeper is still running in a good shape,

Ahh!! Unfortunetly, I have closed my account, so I may have to rebuild the app again after creating new facebook app. Anyways. Let's go further.

I have created ChainReaction Game also which is a multiplayer game.

I have created a wesbite[www.couponbadshah.com] for shopping coupons and offers, which is created in MVC4, and with the help of OWIN, external authentication is handled.

I'm working on another website, named famousbite.com. dont know when I will actually start my coding and publish it. But I have it in my mind to develop and publish to help all food-alcoholic people.

that's it for now,

see you falks.

Sunday, 16 October 2011

About SSRS

SSRS(SQL Server Reporting Services) provides a full range of ready-to-use tools and services to help you create, deploy, and manage reports for your organization, as well as programming features that enable you to extend and customize your reporting functionality. 

Reporting Services is a server-based reporting platform that provides comprehensive reporting functionality for a variety of data sources. Reporting Services includes a complete set of tools for you to create, manage, and deliver reports, and APIs that enable developers to integrate or extend data and report processing in custom applications. Reporting Services tools work within the Microsoft Visual Studio environment and are fully integrated with SQL Server tools and components.

With Reporting Services, you can create interactive, tabular, graphical, or free-form reports from relational, multidimensional, or XML-based data sources called Semantic Query. You can publish reports, schedule report processing, or access reports on-demand. Reporting Services also enables you to create ad hoc reports based on predefined models, and to interactively explore data within the model. You can select from a variety of viewing formats, export reports to other applications, and subscribe to published reports. The reports that you create can be viewed over a Web-based connection or as part of a Microsoft Windows application or SharePoint site. Reporting Services provides the key to your business data.

For more information refer MSDN.

About C#


C# language is intended to be a simple, modern, general-purpose, object-oriented programming language designed by Microsoft. Currently C# 4.0 is available which is released with .net framwork 4.0

C# is the programming language that most directly reflects the underlying Common Language Infrastructure (CLI). Most of its intrinsic types correspond to value-types implemented by the CLI framework. However, the language specification does not state the code generation requirements of the compiler: that is, it does not state that a C# compiler must target a Common Language Runtime, or generate Common Intermediate Language (CIL), or generate any other specific format. 

C# provides a large set of operators, which are symbols that specify which operations to perform in an expression. C# predefines the usual arithmetic and logical operators, as well as a variety of others. In addition, many operators can be overloaded by the user, thus changing their meaning when applied to a user-defined type.

For more information, you can refer C# Wiki or C# MSDN.

Saturday, 15 October 2011

Minesweeper

Hello Friends,
Minesweeper in WPF is same as Minesweeper available in Windows 7.

Still, I am working on it. trying to add extra feature like Tweet from application and facebook status update from application, so that it makes it different from other sources.

I have created four different levels to play this game.
I will update this game to custom mode soon.

People like this because WPF have good UI features.

Right now, i have not uploaded this game because it is not complated yet.
If you are interested to play, just mail me. i will send you the game.
But 1st requirement is your system should have Microsoft .net framwork installed, otherwise it wont work.

Thanks to Nirmit who helped me for Tweeter and Facebook Integration.

Here Screenshots are attached.



For suggestions you can mail me at touseef.kariyania@gmail.com

About me

Hello,
I am Touseef working at IGATE Computer Systems at Pune.

I am extensively working in .Net MVC as well SQL Server.
I have additional knowledge of SSRS Models, SSRS Reports and Designing SSRS Reports.
I have created so many different applications in VC++, windows forms and WPF.

I love to travel and I love to taste new food everytime I go to new place.

I own CouponBadshah.com which provides you coupons, deals, and offers of various online websites. It is pretty helpful to online buyers to get item/tickets at cheaper rate.

I am also working on food blog famousbite.com for food lovers.

For any suggestion, you can make post over here or you can mail me at touseef.kariyania@gmail.com


Thanks.