Risorese Asp.net
Jetpak is Public
Created By: Ghio
Last Modified: 08/30/08
Summary: A Jetpak created on Mon, 11 Aug 2008 08:19:29 GMT

Jetpak Tags:
asp.net c programmingc

Creare uno Zip da programma

using System.IO;
using ICSharpCode.SharpZipLib.Checksums;
using ICSharpCode.SharpZipLib.Zip;

namespace CoolSoft
{
   public class ZIPCreator
   {

      public void CreateZipFile(string ZipFileName, string[] SourceFiles)
      {
         // stream di scrittura dello ZIP
         ZipOutputStream strmZipOutputStream = new ZipOutputStream(File.Create(ZipFileName
            ));

         // Definisco il CRC32
         Crc32 objCrc32 = new Crc32();

         // livello di compressione
         // 0: no compression (store)
         // 9: maximum compression
         strmZipOutputStream.SetLevel(7);

         // scorre l'array con i filenames dei files sorgenti
         foreach (string fileName in SourceFiles)
         {
            // nuova entry nel file ZIP
            ZipEntry newZIPEntry = new ZipEntry(fileName);

            // apre il file sorgente in lettura
            FileStream strmFile = File.OpenRead(fileName);

            // bytes da leggere e già letti
            int bytesRead;

            // definisco un buffer per la lettura da 200000 bytes
            byte[] mBuffer = new byte[200000];

            // azzera il CRC
            objCrc32.Reset();

            // inserisce l'entry nello ZIP
            strmZipOutputStream.PutNextEntry(newZIPEntry);

            // ciclo per la lettura del file sorgente
            while (strmFile.Position < strmFile.Length)
            {
               bytesRead = strmFile.Read(mBuffer, 0, mBuffer.Length);
               strmZipOutputStream.Write(mBuffer, 0, bytesRead);
               objCrc32.Update(mBuffer, 0, bytesRead);
            }

            // imposta il CRC del nuovo file all'interno dello ZIP
            newZIPEntry.Crc = objCrc32.Value;

            // imposta le caratteristiche del nuovo file
            newZIPEntry.DateTime = File.GetCreationTime(fileName);
            newZIPEntry.Size = strmFile.Length;

            // chiude il file sorgente
            strmFile.Close();
         }

         // chiude il file ZIP
         strmZipOutputStream.Finish();
         strmZipOutputStream.Close();
      }
   }
}


From: http://www.dotnet2themax.it/ShowContent.aspx?ID=a67d2078-e4b9-4f0c-a0d3-3f6f984ec04c&Page=2&#RET

Resettare Password

string username = "user";
string password = "pass@word";
MembershipUser mu = Membership.GetUser(username);
mu.ChangePassword(mu.ResetPassword(), password);
 
 
questo è relativo al webconfig
<membership defaultProvider="SqlMembershipProvider" userIsOnlineTimeWindow="15">
<providers>
<clear/>
<add name="SqlMembershipProviderOther" type="SqlProviderOneShot.SqlMembershipProvider"
requiresQuestionAndAnswer="false"
connectionStringName="EmailEmailConnectionString" applicationName="EmailEmail"
enablePasswordRetrieval="false" enablePasswordReset="true"
requiresUniqueEmail="true" passwordFormat="Hashed"
minRequiredNonalphanumericCharacters="0" writeExceptionsToEventLog="false"
minRequiredPasswordLength="1" passwordStrengthRegularExpression=""
passwordAttemptWindow="10" maxInvalidPasswordAttempts="8"/>
providers>
membership>

From: http://peterkellner.net/2007/02/15/resetpasswordaspnet/

Funzione per cambiare il titolo delle pagine da sitemap

VB 
Private Function GetPageTitleBasedOnSiteNavigation() As String
If SiteMap.CurrentNode Is Nothing Then
Throw New ArgumentException("currentNode cannot be Nothing")
End If

'We are visiting a page defined in the site map - build up the
'page title based on the site map node's place in the hierarchy

Dim output As String = String.Empty
Dim currentNode As SiteMapNode = SiteMap.CurrentNode

While currentNode IsNot Nothing
If output.Length > 0 Then
output = currentNode.Title & " :: " & output
Else
output = currentNode.Title
End If

currentNode = currentNode.ParentNode
End While

Return output
End Function
C#
 public static string GetPageTitleBasedOnSiteNavigation(SiteMapNode currentnode)
{
string output = string.Empty;
if(currentnode==null)
{
return output;
}
while (currentnode!=null)
{
if (output.Length > 0)
{
output = currentnode.Title + " :: " + output;
}
else
{
output = currentnode.Title;
}
currentnode = currentnode.ParentNode;
}
return output;
}

From: http://aspnet.4guysfromrolla.com/articles/051006-1.aspx

Assegnare un tema in base al profilo

protected void Page_PreInit()
  {
    if (Profile.FavoriteColor != "")
      Page.Theme = Profile.FavoriteColor;
  }
  

From: http://quickstarts.asp.net/QuickStartv20/util/srcview.aspx?path=~/aspnet/samples/themes/ProfileTheme.src&file=ProfileTheme_cs.aspx&lang=C%23+Source




ADVERTISING