Wednesday, November 05, 2014

How to delete a file or folder with a path too long?

I have come across a situation where I am unable to delete a folder? Interesting right. I tired different ways to delete like how we does in Windows like every time we do. But no luck. After I did some research I found a way to delete file or folder which is too long to delete.

Here is the error message you will get when you try to delete these files or folders “Destination Path Too Long:  The file name(s) would be too long for the destination folder.  You can shorten the file name and try again, or try a location that has a shorter path.

Usually windows cannot delete file path greater than 255 characters.

So here is the simple way to delete these folders by doing Map Drive to that location. Here is how we can do using command prompt.

  1. Start a command prompt (no admin privileges needed)
  2. Use cd to navigate to the folder you want to go (you can use tab to autocomplete names)
  3. Type subst Z:  to create the drive letter association. (instead of the . you can also type the entire path)
    C:\>subst Z:  d:\Java.Works\adt-bundle-windows-x86_64-20140702
  4. Now in explorer you have a new letter in your computer. Go to it and do whatever you need to do to like by navigate to the files that have long names. You should now be able to rename/delete/etc them. The reason this works is because the path itself is no longer containing >255 chars
  5. Go back to your cmd window and type subst /d Z: to remove the drive like this C:\>subst /d Z:

This worked for me. Hope it works for you as well. Good luck

Friday, October 24, 2014

How do you clear temporary files in an ASP.NET website project?

All you need to do is stop IIS from Services, go to c:\Windows\Microsoft.NET\Framework\v4.0.30319\ or respective Framework directory, open the Temporary ASP.NET Files and delete the folders

What happens when we delete these files? Is it safe?

Yes, it's safe to delete these, although it may force a dynamic recompilation of any .NET applications you run on the server.

For background, see the Understanding ASP.NET dynamic compilation article on MSDN.

Thursday, October 16, 2014

How To Disable Right Click Using jQuery

There are many different ways where we can disable right click on browser but using jQuery its very easy with one line of code.

Add the below code into the head section of your web page.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(document).bind("contextmenu", function (e) {
e.preventDefault();
});
});
</script>

How To Show A Message When DataList Is Empty

DataList doesn’t have EmptyDataTemplate like GridView or ListView, Here is how we can achieve use FooterTemplate in DataList

<FooterTemplate>
<asp:Label ID="lblEmpty" Text="No test types found." runat="server"
Visible='<%#bool.Parse((SearchValuesList.Items.Count == 0).ToString())%>'> </asp:Label>
</FooterTemplate>


Sunday, September 21, 2014

How To Encrypt Stored Procedure In SQL Server

There are some situations where business logics wants to hide the logic implementation, in those scenarios schema of the stored procedure can be encrypted.

Use AdventureWorks2008
go

CREATE PROCEDURE uspEncryptedPersonAddress
WITH ENCRYPTION
AS
BEGIN
SET NOCOUNT ON
SELECT * FROM Person.Address
END


If some one try to view using sp_helptext this is what they see


The text for object 'uspEncryptedPersonAddress' is encrypted.