Tags » .NET Framework

PowerShell Objects Part 1: No More Parsing!

One of the first things to know about PowerShell in order to wield it effectively is its object-based paradigm. If you are trying to parse strings in PowerShell scripts, it’s likely that there is a better way. 720 more words

PowerShell

Microsoft might finally be committing to open source

Microsoft is known for keeping its programming secrets to itself. But under CEO Satya Nadella, the maker of proprietary behemoths like Windows and Microsoft Office is starting to show up in the world of open-source software, whose code is public for anyone to see, borrow from and tinker with. 369 more words

Blog migrado para o Azure

Boa noite, pessoal!! Tudo certo?

Estou passando para avisar que acabei de migrar o blog para o azure, segue o link http://wenndersantos.azurewebsites.net/

Porque fiz isso? Boa pergunta, sei lá. 43 more words

.NET Framework

Serialize and Deserialize InfoPath form and extract the attachment using WebClient in C#

Hi,

Suppose this is our InfoPath form

First we will generate the class for the above InfoPath form

http://nishantrana.me/2014/07/13/generate-a-c-class-from-an-infopath-form/

The sample code


myFields invoice = null;
WebClient webclient = new WebClient();
webclient.UseDefaultCredentials = true;

using (Stream fileStream = webclient.OpenRead("http://server:5000/formlibrary/FirstForm.xml?NoRedirect=true"))
{
if (fileStream != null)
{
XmlTextReader reader = new XmlTextReader(fileStream);

reader.Read();
reader.MoveToContent();

XmlSerializer xser = new XmlSerializer(typeof(myFields));
myFields invoiceInfopath = (myFields)xser.Deserialize(reader);
byte[] b = invoiceInfopath.field2;

// filename
int nameBufferLen = b * 2;
byte[] fileNameBufffer = new Byte;

for (int i = 0; i < nameBufferLen; i++)
{
fileNameBufffer[i] = b;
}

char[] charFileName = UnicodeEncoding.Unicode.GetChars(fileNameBufffer);
string fileName = new string(charFileName);
fileName = fileName.Substring(0, fileName.Length - 1);

// attchment
byte[] fileContent = new byte;

for (int i = 0; i < fileContent.Length; i++)
{
fileContent[i] = b;
}

FileStream fs = new FileStream(@"C:\test\" + fileName, FileMode.Create);
fs.Write(fileContent, 0, fileContent.Length);
fs.Close();
}

… 11 more words
C#

How to Read the InfoPath content and extract the attachment using XMLDocument in C#

The InfoPath form:-

The namespace and the field1 that is node that contains the attachment

Sample Code:


XmlDocument myDoc = new XmlDocument();
myDoc.Load(@"C:\test\form.xml");

// specify the name space
XmlNamespaceManager ns = new XmlNamespaceManager(myDoc.NameTable);
ns.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2014-07-12T15:29:09");

// the node that contains the attachment
XmlNodeList nl = myDoc.SelectNodes("/my:myFields/my:group1/my:group2/my:field1", ns);
foreach (XmlNode n in nl)
{
string s = n.InnerText;
byte[] b = Convert.FromBase64String(s);
int nameBufferLen = b * 2;

// file name buffer to get the filename with extension
byte[] fileNameBufffer = new Byte;

for (int i = 0; i < nameBufferLen; i++)
{
fileNameBufffer[i] = b;
}
char[] charFileName = UnicodeEncoding.Unicode.GetChars(fileNameBufffer);
string fileName = new string(charFileName);
fileName = fileName.Substring(0, fileName.Length - 1);

// byte array for the remaining content
byte[] fileContent = new byte;

for (int i = 0; i < fileContent.Length; i++)
{
fileContent[i] = b;
}

FileStream fs = new FileStream(@"C:\test\" + fileName, FileMode.Create);
fs.Write(fileContent, 0, fileContent.Length);
fs.Close();

}

… 15 more words
.NET Framework

Generate a C# class from an InfoPath form

To generate a C# class from change the extension to .cab from .xsn.

Open and copy the content of cab file to a separate folder… 20 more words

C#

Installing .NET Framework 3.5 to Server 2012 - Alternate Source File Path

.Net Framework Installation Error – You Need to Specify an Alternate Source File Path

Command line to Install .NET Framework on 2012 server

Insert the Windows 2012 DVD into the drive or if the server is VM mount the iso file through the VM properties or mount the DVD using another tool like WinCDEMU. 39 more words

Windows