473,394 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Setting Filename to a text field

Below code extracts the attachment and store it a share with actual
attachment name. How can I set filename to a text field's value in my
infopath form? So if attached file name is FileA.txt but the value in a text
field (FinalName) in form is FileXYZ.txt, file should be save to share as
FileXYZ.txt
-----------------------------------------------------------------------------------------------------
public void Submit_Clicked(object sender, ClickedEventArgs e)
{

// Write your code here.

XPathNavigator docXN = this.CreateNavigator();

XPathNavigator opnXN = docXN.SelectSingleNode("/my:myFields/my:Attachment",
this.NamespaceManager);

byte[] attachmentNodeBytes = Convert.FromBase64String(opnXN.ToString());

int fnLength = attachmentNodeBytes[20] * 2;

byte[] fnBytes = new byte[fnLength];

for (int i = 0; i < fnBytes.Length; i++)

{

fnBytes[i] = attachmentNodeBytes[24 + i];

}

char[] charFileName = System.Text.UnicodeEncoding.Unicode.GetChars(fnByt es);

string fileName = new string(charFileName);

fileName = fileName.Substring(0, fileName.Length - 1);

byte[] fileContents = new byte[attachmentNodeBytes.Length - (24 +
fnLength)];

for (int i = 0; i < fileContents.Length; ++i)

{

fileContents[i] = attachmentNodeBytes[24 + fnLength + i];

}

// Below is for storing to a Share

FileStream fs = new FileStream(@\\Server\EmpFiles\ + fileName,
FileMode.Create);

fs.Write(fileContents, 0, fileContents.Length); fs.Close();

----------------------------------------------------------------------------------------------------
Jun 27 '08 #1
4 2118
On Thu, 26 Jun 2008 11:15:57 -0700, andyoye <an*****@nospam.comwrote:
Below code extracts the attachment and store it a share with actual
attachment name. How can I set filename to a text field's value in my
infopath form? So if attached file name is FileA.txt but the value in a
text
field (FinalName) in form is FileXYZ.txt, file should be save to share as
FileXYZ.txt
Just use the value from your text field rather than from the file
attachment when you initialize the "fileName" variable.

Pete
Jun 27 '08 #2
How can I initialize "fileName" to get the value of form text field
"FinalName"

Thanks
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Thu, 26 Jun 2008 11:15:57 -0700, andyoye <an*****@nospam.comwrote:
>Below code extracts the attachment and store it a share with actual
attachment name. How can I set filename to a text field's value in my
infopath form? So if attached file name is FileA.txt but the value in a
text
field (FinalName) in form is FileXYZ.txt, file should be save to share as
FileXYZ.txt

Just use the value from your text field rather than from the file
attachment when you initialize the "fileName" variable.

Pete

Jun 27 '08 #3
On Jun 27, 12:42*pm, "andyoye" <andy...@nospam.comwrote:
How can I initialize "fileName" to get the value of *form text field
"FinalName"
fileName = FinalName.Text;

?

Jon
Jun 27 '08 #4
On Fri, 27 Jun 2008 10:33:49 -0700, andyoye <an*****@nospam.comwrote:
"FinalName" is the ID of infopath "text box" control node/field.
For what it's worth, it appears that your REAL question was "how do I get
the string value from an InfoPath 'text box' control?"

All that other stuff is just irrelevant.

You will find that you get your answers much more quickly, and much more
accurately, if you ask the questions correctly. :)

Pete
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John Flynn | last post by:
hi, having problems reading from and writing back to the same file. basically, i want to read lines of text from a file and reverse them and write them back to the same file.. it has to...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
3
by: Steve Yerkes | last post by:
There seems to be way too much confusion over how to set focus on the a field using a field validator. I looked all over the web and found people trying to do this, but not getting anywhere. There...
5
by: Ariel Dolan | last post by:
Can I use HtmlInputFile to only get the selected file name but not actually upload the file? Clicking the control's Browse button let's the user select a file. All I need is the HtmlInputFile...
15
by: tshad | last post by:
I am trying to put an persons email address in a response I am sending another person. I can get it to work by doing the following: message.Body = resumeTop & vbCrLf & vbCrLf & "For Applicant:...
3
by: UJ | last post by:
How can I add a browse button to my asp.net page? What I need is a button they can press that will then let them select the file to upload to the server. And if anybody has any good code on how...
1
by: simon | last post by:
I have an unbound RTF2 control in an Access 2003 form which I set to show either unformatted text or else text with words and sentences highlighted. I do this by setting the PlainText property,...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
0
VietPP
by: VietPP | last post by:
Hi all, I've asked too much question in this day, hehe. I'm trying to export my table data in OracleDB to excel. The problem is my charset in database is US7ACSII (using Vietnamese font), when...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.